outstandingWorkflowRequests log {ts '2025-06-18 10:16:51'} SQL declare @ownerId int = 709 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 4821132 ; with openRequests as ( select requestId, requestKey, toUserId, fromUserId, fromEmail, requestURL, handlerTemplatePath, requestTime, disposition, config, requestTitle, requestSubject, response, responseTime, requestTrackingCode, responseDueDate, requestAnnotation, requestSent, sendCount, case when toUserId = @userId then 'IN' else 'OUT' end as direction, cast( case when ownerId = @ownerId and ownerType = @ownerType then 1 else 0 end as bit ) as homeRequest from tbl_WRK_UserRequests with (nolock) where disposition = '?' and ownerId = @ownerId and ownerType = @ownerType and ( fromUserId = @userId or toUserId = @userId ) ), openRequestsFormatted as ( select r.*, f.firstName + ' ' + f.lastName as fromFullName, t.firstName + ' ' + t.lastName as toFullName from openRequests r left outer join tbl_Fspro_Members f with (nolock) on f.fspro_userId = r.fromUserId left outer join tbl_Fspro_Members t with (nolock) on t.fspro_userId = r.toUserId ), result as ( select * from openRequestsFormatted ) , result_mappedData as ( select * from result ) , result_preData as ( select * from result_mappedData with (nolock) where ( 1 = 1 ) ) , result_data as ( select * from result_preData ) , result_return as ( select * from result_data where 1 = 1 order by requestTime offset 0 rows fetch next 10000000 rows only ) , result_result as ( select ( select count(*) from result_data ) as totalCount, ( select * from result_return for json auto, include_null_values ) as data ) select * from result_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER {ts '2025-06-18 10:22:26'} SQL declare @ownerId int = 709 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 4821132 ; with openRequests as ( select requestId, requestKey, toUserId, fromUserId, fromEmail, requestURL, handlerTemplatePath, requestTime, disposition, config, requestTitle, requestSubject, response, responseTime, requestTrackingCode, responseDueDate, requestAnnotation, requestSent, sendCount, case when toUserId = @userId then 'IN' else 'OUT' end as direction, cast( case when ownerId = @ownerId and ownerType = @ownerType then 1 else 0 end as bit ) as homeRequest from tbl_WRK_UserRequests with (nolock) where disposition = '?' and ownerId = @ownerId and ownerType = @ownerType and ( fromUserId = @userId or toUserId = @userId ) ), openRequestsFormatted as ( select r.*, f.firstName + ' ' + f.lastName as fromFullName, t.firstName + ' ' + t.lastName as toFullName from openRequests r left outer join tbl_Fspro_Members f with (nolock) on f.fspro_userId = r.fromUserId left outer join tbl_Fspro_Members t with (nolock) on t.fspro_userId = r.toUserId ), result as ( select * from openRequestsFormatted ) , result_mappedData as ( select * from result ) , result_preData as ( select * from result_mappedData with (nolock) where ( 1 = 1 ) ) , result_data as ( select * from result_preData ) , result_return as ( select * from result_data where 1 = 1 order by requestTime offset 0 rows fetch next 10000000 rows only ) , result_result as ( select ( select count(*) from result_data ) as totalCount, ( select * from result_return for json auto, include_null_values ) as data ) select * from result_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER