tasks log {ts '2025-07-08 08:51:17'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:36'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:40'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:43'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Completed' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:44'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Cancelled' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:45'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Completed' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:46'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:46'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:47'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Cancelled' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:51:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Completed' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:52:42'} SQL {ts '2025-07-08 08:52:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) and ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) and ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:52:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:52:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:52:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) and ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:54:50'} SQL {ts '2025-07-08 08:54:50'} SQL {ts '2025-07-08 08:54:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:54:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:54:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:55:15'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200433 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 08:55:37'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Cancelled' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:55:38'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Completed' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:55:39'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:55:40'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:55:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Completed' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:07'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:12'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200433' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:16'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Cancelled' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:17'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:19'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:20'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:21'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:22'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:24'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200433' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:27'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200433' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:58:28'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200433' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:36'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:39'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:48'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'On Hold' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:49'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Complete' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Cancelled' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 08:59:52'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:04:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:05:46'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:05:48'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200444' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:05:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:06:25'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:09:46'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:10:00'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:10:10'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200445' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:10:13'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:13:15'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200433 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:13:30'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:14'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200433 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:16:27'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:17:02'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:05'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Complete' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:10'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Complete' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:30'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:52'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:54'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:55'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:56'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:17:57'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:10'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:11'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:12'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:13'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:14'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:15'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:27'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:29'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:44'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:18:56'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '13523348' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:16'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:25'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:27'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:35'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:36'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:37'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:38'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:43'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:19:59'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:00'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:02'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:17'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:20'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:22'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:25'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:27'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:31'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:20:53'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:01'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:04'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:05'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:07'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:14'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:25'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '8926922' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:29'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '8926922' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:46'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:52'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:25:55'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:00'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:09'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:11'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:13'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:13'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:14'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:15'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:26:17'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200433' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:27:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:27:44'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:27:55'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:27:58'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:00'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:08'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '8926922' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:10'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '8926922' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:15'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:17'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:19'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:20'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'On Hold' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:21'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:28:22'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [partnerId] = '7576234' ) and ( [partnerType] = 'OPR' ) ) ) and ( ( [statusDisplay] = 'Complete' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 09:30:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:30:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:30:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:30:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:30:42'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:31:12'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200434 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:11'} SQL {ts '2025-07-08 09:32:11'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:11'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:11'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:11'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:32:21'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200434 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 09:33:43'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:34:27'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200434 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:34:35'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 3811100 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:34:51'} SQL {ts '2025-07-08 11:34:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:34:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:34:51'} SQL {ts '2025-07-08 11:34:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:38:01'} SQL {ts '2025-07-08 11:38:01'} SQL {ts '2025-07-08 11:38:01'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4903737 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4903737' ) or ( [assignedTo] = '4903737' ) ) ) and ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4903737 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4903737' ) or ( [assignedTo] = '4903737' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4903737 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4903737' ) or ( [assignedTo] = '4903737' ) ) ) and ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:38:01'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4903737 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4903737' ) or ( [assignedTo] = '4903737' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:38:01'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4903737 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4903737' ) or ( [assignedTo] = '4903737' ) ) ) and ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:33'} SQL {ts '2025-07-08 11:39:33'} SQL {ts '2025-07-08 11:39:33'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4879325 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4879325' ) or ( [assignedTo] = '4879325' ) ) ) and ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4879325 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4879325' ) or ( [assignedTo] = '4879325' ) ) ) and ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4879325 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4879325' ) or ( [assignedTo] = '4879325' ) ) ) and ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:33'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4879325 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4879325' ) or ( [assignedTo] = '4879325' ) ) ) and ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:33'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 4879325 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [requestedBy] = '4879325' ) or ( [assignedTo] = '4879325' ) ) ) and ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:59'} SQL {ts '2025-07-08 11:39:59'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Cancelled' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:59'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Past Due' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'Complete' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:59'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( [statusDisplay] = 'On Hold' ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:39:59'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:41:47'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:42:56'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where [taskId] = 200446 ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:43:08'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5102807 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate desc offset 0 rows fetch next 50 rows only ) , tasks_result as ( select ( select count(*) from tasks_data ) as totalCount, ( select * from tasks_return for json auto, include_null_values ) as data ) select * from tasks_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-07-08 11:43:46'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:43:52'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:44:25'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:44:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:44:53'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:45:04'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:45:16'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:45:18'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:52:52'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:52:54'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:53:38'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:53:59'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200448' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:54:02'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:54:10'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:54:14'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:54:45'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:54:50'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200449' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:54:51'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200449' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:02'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:04'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:12'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:22'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200449' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:26'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:28'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:29'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:33'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:34'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by dueDate offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:36'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( [taskId] = '200447' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return {ts '2025-07-08 11:55:47'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-07-08' ; declare @currentUserId int = 5517598 ; with usersWatchList as ( select distinct wl.ownerId, wl.ownerType, wl.subjectId as taskId from tbl_CRM_WatchList wl with (nolock) where ownerId = @ownerId and ownerType = @ownerType and subjectType = 'WRT' and active = 'Y' and fspro_userId = @currentUserId ), tasks as ( select t.taskId, t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, case when t.disposition = 'X' then 'Complete' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay, t.dispositionUser, d.firstName + ' ' + d.lastName as dispositionUserFullName, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName as requestedByFirstName, r.lastName as requestedByLastName, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName as assignedToFirstName, a.lastName as assignedToLastName, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, cast( case when t.disposition = '?' and t.dueDate < @today then 1 else 0 end as bit ) as pastDue, t.partnerId, t.partnerType, t.partnerContactId, case when t.partnerId is null then null else json_query( '{ "partnerType" : "' + coalesce( t.partnerType, '') + '", "partnerId":' + cast( t.partnerId as varchar ) + ', "contactId" : ' + case when nullif( t.partnerContactId, 0 ) is null then 'null' else cast( t.partnerContactId as varchar ) end + ' }' ) end as connectedTo, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, json_query( coalesce( t.jsonData, '{}' )) as jsonData, t.acknowledged, t.taskTypeId, p.projectId, p.projectName, t.repeating, t.frequency, coalesce( t.repeatFrom, t.dueDate ) as repeatFrom, t.repeatUntil, t.sourceTaskId, cast( case when wl.taskId is not null then 1 else 0 end as bit ) watching from tbl_WRK_Tasks t with (nolock) left outer join tbl_WRK_Projects p with (nolock) on p.ownerId = t.ownerId and p.ownerType = t.ownerType and p.projectId = t.projectId inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 left outer join tbl_FSPro_Members d with (nolock) on d.fspro_userId = t.dispositionUser and d.ownerId > 0 left outer join usersWatchList wl with (nolock) on wl.ownerId = t.ownerId and wl.ownerType = t.ownerType and wl.taskId = t.taskId where t.ownerId = @ownerId and t.ownerType = @ownerType ) , tasks_mappedData as ( select * from tasks ) , tasks_preData as ( select * from tasks_mappedData with (nolock) where ( ( ( ( [statusDisplay] = 'Open' ) or ( [statusDisplay] = 'Past Due' ) ) ) and ( ( [createdBy] = '5517598' ) or ( [assignedTo] = '5517598' ) ) ) ) , tasks_data as ( select * from tasks_preData ) , tasks_return as ( select * from tasks_data where 1 = 1 order by taskDescription offset 0 rows fetch next 10000000 rows only ) select * from tasks_return