Operation Details
Description: Returns the deadline date time and reserved by user name of the tasks that are due for the members of a specified organization unit during a specified time period.
Sterotype: nsmulti
SQL
SELECT
  w.deadlineTime,
  t.reservedBy
INTO
  :deadlineDateTime,
  :reservedBy 
FROM
  Task t 
  
  LEFT OUTER JOIN
  
  WorkflowDeadline w 
  ON (t.taskID = w.taskID) 
WHERE w.deadlineTime >= :fromDeadlineDateTime 
  AND w.deadlineTime < :toDeadlineDateTime 
  AND 
  (
    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 
        ) 
      ) 
    ) 
  ) 
ORDER BY w.deadlineTime