UFN_BBWORKFLOW_SERVICE_BUILDMESSAGE_TASKCOMPLETED

Returns an xml TaskCompleted message for use with the workflow service queue.

Return

Return Type
xml

Parameters

Parameter Parameter Type Mode Description
@BBWORKFLOWTASKID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN
@CURRENTAPPUSERID uniqueidentifier IN
@ISCANCELLED bit IN

Definition

Copy


CREATE function dbo.UFN_BBWORKFLOW_SERVICE_BUILDMESSAGE_TASKCOMPLETED(@BBWORKFLOWTASKID uniqueidentifier, @CHANGEAGENTID uniqueidentifier, @CURRENTAPPUSERID uniqueidentifier, @ISCANCELLED bit)
returns xml
as

begin

    declare @taskid nvarchar(38);
    set @taskid=cast(@BBWORKFLOWTASKID as nvarchar(38));


    declare @BBWORKFLOWINSTANCEINFOID uniqueidentifier;
    select @BBWORKFLOWINSTANCEINFOID=BBWORKFLOWINSTANCEINFOID from dbo.BBWORKFLOWTASK where ID = @BBWORKFLOWTASKID;


    declare @id nvarchar(38);
    set @id=cast(@BBWORKFLOWINSTANCEINFOID as nvarchar(38));

    declare @catalogId nvarchar(38);

    declare @workflowInstanceId nvarchar(38);

    select 
    @workflowInstanceId =cast(WORKFLOWINSTANCEID as nvarchar(38)),  
    @catalogId=BBWORKFLOWCATALOGID 
    FROM dbo.BBWORKFLOWINSTANCEINFO WHERE ID=@BBWORKFLOWINSTANCEINFOID;


    if @CURRENTAPPUSERID is null set @CURRENTAPPUSERID='00000000-0000-0000-0000-000000000000';

    if @CHANGEAGENTID is null set @CHANGEAGENTID='00000000-0000-0000-0000-000000000000';


    declare @cancelText nvarchar(8);
    if @ISCANCELLED = 1
        set @cancelText=N'true';
    else
        set @cancelText=N'false';


    declare @msg nvarchar(max);
    set @msg=
N'<TaskCompletedNotification xmlns="urn:blackbaud-workflow-contracts">
    <TaskID>' + @taskid + N'</TaskID>
    <IsCancelled>' + @cancelText + N'</IsCancelled>    
    <WorkflowInstanceRecordID>' + @id + N'</WorkflowInstanceRecordID>
    <WorkflowSpecCatalogID>' + @catalogId + N'</WorkflowSpecCatalogID>
    <ChangeAgentId>' + cast(@CHANGEAGENTID as nvarchar(38)) + N'</ChangeAgentId>
    <CurrentAppUserID>' + cast(@CURRENTAPPUSERID as nvarchar(38)) + N'</CurrentAppUserID>
     <WorkflowInstanceId>' + @workflowInstanceId + N'</WorkflowInstanceId>
</TaskCompletedNotification>';

    declare @xml xml ;
    set @xml = CONVERT( xml, @msg, 1);

    return @xml;

end