Operation Details
Description: Searches for activity records where the start and end date-times overlap with the start and end date times provided in the key for the specified organization. The time status codes must match the time status codes provided.
Sterotype: nsmulti
SQL
SELECT
  activityID,
  userName,
  organisationID,
  subject,
  activityTypeCode,
  startDateTime,
  endDateTime,
  allDayInd,
  locationID,
  locationName,
  priorityCode,
  timeStatusCode,
  notes,
  recurrenceID,
  caseID,
  concernRoleID
INTO
  :activityID,
  :userName,
  :organisationID,
  :subject,
  :activityTypeCode,
  :startDateTime,
  :endDateTime,
  :allDayInd,
  :locationID,
  :locationName,
  :priorityCode,
  :timeStatusCode,
  :notes,
  :recurrenceID,
  :caseID,
  :concernRoleID 
FROM
  Activity 
WHERE 
  (
    userName = :userName 
    OR organisationID = :organisationID 
  ) 
  AND 
  (
    activityID <> :activityID 
    OR :activityIDIsNull <> '0' 
  ) 
  AND 
  (
    recurrenceID IS NULL 
    OR recurrenceID <> :recurrenceID 
    OR :recurrenceIDIsNull <> '0' 
  ) 
  AND 
  (
    startDateTime < :endDateTime 
    AND endDateTime > :startDateTime 
  ) 
  AND 
  (
    timeStatusCode = :busyStatusCode 
    OR timeStatusCode = :outStatusCode 
  ) 
  AND recordStatusCode = :recordStatusCode