UFN_BBWORKFLOW_SERVICE_BUILDMESSAGE_CANCELWORKFLOW

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

Return

Return Type
xml

Parameters

Parameter Parameter Type Mode Description
@BBWORKFLOWINSTANCEINFOID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN
@CURRENTAPPUSERID uniqueidentifier IN
@REASON nvarchar(500) IN

Definition

Copy


create function dbo.UFN_BBWORKFLOW_SERVICE_BUILDMESSAGE_CANCELWORKFLOW(@BBWORKFLOWINSTANCEINFOID uniqueidentifier, @CHANGEAGENTID uniqueidentifier, @CURRENTAPPUSERID uniqueidentifier, @REASON nvarchar(500))
returns xml
as

begin

    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 @REASON is null  set @REASON= N'';

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

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


    declare @msg nvarchar(max);
    set @msg=
N'<CancelWorkflowRequest xmlns="urn:blackbaud-workflow-contracts">
      <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>
      <Reason><![' + N'CDATA[' + @REASON + N']' + N']></Reason>
</CancelWorkflowRequest>';

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

    return @xml;

end