Operation Details
Description: Returns a list of the task details that are associated with the members of a specified organization unit. Depending on the input parameter data, the function may return all of the tasks associated with the members of a specified organization unit, all of the reserved tasks associated with the members of a specified organization unit or all the tasks that have not yet been reserved for the members of a specified organization unit.
Sterotype: nsmulti
SQL
SELECT
  t.taskID,
  t.priority,
  t.assignedDateTime,
  t.wdoSnapshot,
  t.overflowInd,
  t.versionNo,
  w.deadlineTime
INTO
  :taskID,
  :taskPriority,
  :taskAssignedDateTime,
  :taskWDOSnapshot,
  :taskWDOOverflowInd,
  :versionNo,
  :taskDeadlineDateTime 
FROM
  Task t 
  
  LEFT OUTER JOIN
  
  WorkflowDeadline w 
  ON (t.taskID = w.taskID) 
WHERE 
  (
    t.taskID IN 
    ( 
    SELECT
      taskID 
    FROM
      TaskAssignment u 
    WHERE u.assigneeType = 'RL9' 
      AND u.relatedName IN 
      ( 
      SELECT
        DISTINCT Users.userName 
      FROM
        Users,
        PositionHolderLink,
        Position,
        OrgUnitPositionLink 
      WHERE Users.userName = PositionHolderLink.userName 
        AND PositionHolderLink.positionID = Position.positionID 
        AND Position.recordStatus = :positionRecordStatus 
        AND Position.fromDate <= :currentDate 
        AND 
        (
          Position.toDate >= :currentDate 
          OR Position.toDate IS NULL 
        ) 
        AND 
        (
          PositionHolderLink.organisationStructureID = :organizationStructureID 
        ) 
        AND OrgUnitPositionLink.positionID = Position.positionID 
        AND OrgUnitPositionLink.organisationUnitID = :organizationUnitID 
        AND OrgUnitPositionLink.recordStatus = :orgUnitPositionLinkRecordStatus 
        AND PositionHolderLink.recordStatus = :positionHolderLinkRecordStatus 
        AND PositionHolderLink.fromDate <= :currentDate 
        AND 
        (
          PositionHolderLink.toDate >= :currentDate 
          OR PositionHolderLink.toDate IS NULL 
        ) 
        AND 
        (
          Users.statusCode = :userRecordStatus 
        ) 
      ) 
    ) 
  ) 
  AND 
  (
    
    (
      :allOrgUnitTasksInd = '0' 
      OR 
      (
        t.reservedBy IS NULL 
        OR t.reservedBy IS NOT NULL 
      ) 
    ) 
    AND 
    (
      :allReservedOrgUnitTasksInd = '0' 
      OR t.reservedBy IS NOT NULL 
    ) 
    AND 
    (
      :allAssignedOrgUnitTasksInd = '0' 
      OR t.reservedBy IS NULL 
    ) 
  ) 
ORDER BY w.deadlineTime ASC