Database SQL Operation: WorkQueue.searchWorkQueueUserOrgUnitTasks
Description: | Returns a count of all the tasks for all of the organization units that the specified user is subscribed to. |
Sterotype: | nsmulti |
SELECT
ta.relatedID,
count(*)
INTO
:workQueueID,
:numberOfRecords
FROM
TaskAssignment ta
WHERE ta.assigneeType = :assigneeType
AND ta.relatedID IN
(
SELECT
wq.workQueueID
FROM
WorkQueue wq
WHERE wq.workQueueID IN
(
SELECT
workQueueID
FROM
WorkQueueSubscription wqs
WHERE wqs.subscriberType = :subscriberType
AND wqs.subscriberID IN
(
SELECT
DISTINCT ou.organisationUnitID
FROM
Users u ,
PositionHolderLink ph ,
Position p ,
OrgUnitPositionLink oup ,
OrganisationUnit ou
WHERE u.userName = :userName
AND u.userName = ph.userName
AND ph.positionID = p.positionID
AND p.positionID = oup.positionID
AND oup.organisationUnitID = ou.organisationUnitID
AND ph.recordStatus = :recordStatus
AND :currentDate >= ph.fromDate
AND
(
:currentDate <= ph.toDate
OR ph.toDate IS NULL
)
)
)
)
GROUP
BY ta.relatedID
|