Using CreateWorkflowFromModelId through SOAP API

nigeld92054100

04-10-2019

Does anyone have any experience using CreateWorkflowFromModelId method on the nms:operation schema?

I've tried to call it using a valid workflow template, but every time it returns "0" for the plWorkflowId, and there is no workflow object being created. I use SOAPUI to make the call using the nms:operation schema WSDL.

I've also tried adding an operationPlanning element in <urn:elemOperationPlanning>, but this also returns the same result.

Request XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:nms:operation">

   <soapenv:Header/>

   <soapenv:Body>

      <urn:CreateWorkflowFromModelId>

         <urn:sessiontoken>XXXXXXXXXXXXXXXXXXX</urn:sessiontoken>

         <urn:lModelId>1234</urn:lModelId>

         <urn:elemOperationPlanning></urn:elemOperationPlanning>

      </urn:CreateWorkflowFromModelId>

   </soapenv:Body>

</soapenv:Envelope>

Response XML:

<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="urn:nms:operation" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

   <SOAP-ENV:Body>

      <CreateWorkflowFromModelIdResponse SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns="urn:nms:operation">

         <plWorkflowId xsi:type="xsd:int">0</plWorkflowId>

      </CreateWorkflowFromModelIdResponse>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

<urn:elemOperationPlanning>

Accepted Solutions (1)

Accepted Solutions (1)

nigeld92054100

07-10-2019

I have solved this using the CreateInstanceFromModel method on xtk:queryDef. Here is the sample XML I used to create a workflow from a template, and then associate ("patch") the workflow to a campaign object:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xtk:queryDef">

   <soapenv:Header/>

   <soapenv:Body>

      <urn:CreateInstanceFromModel>

         <urn:sessiontoken>XXXXXXXXXXXXXXXXXXX</urn:sessiontoken>

         <urn:strSchema>xtk:workflow</urn:strSchema>

         <urn:lModelId>1234</urn:lModelId>

         <urn:elemDiff>

            <workflow label="Email workflow" operation-id="9876"/>

         </urn:elemDiff>

      </urn:CreateInstanceFromModel>

   </soapenv:Body>

</soapenv:Envelope>

Answers (4)

Answers (4)

somasundaramhal

04-10-2019

Hi  nigeld92054100,

I used the same request that you've used. It works! You need to link the campaign id to the workflow template. However, I was able to create only one workflow in the campaign using this api call. If I try to execute the same api call again, that didn't work.

1840255_pastedImage_0.png

nigeld92054100

04-10-2019

Thanks, but I'm not sure I follow

You had to manually update the workflow template with the campaign id? And then when you executed the CreateWorkflowFromModelId method it automatically assigned a new workflow to that specific campaign?

I could not replicate this behavior. Also, I want to be able to create a new workflow from a template for any campaign, not one specifically assigned to a campaign object.

Do you know of any other way to create workflows from a template and assign to any campaign? Other than Spawn (+ derivatives) or CreateWorkflowFromModelId? There must be a way or it wouldn't be possible through the console either.

nigeld92054100

04-10-2019

Thanks for the reply. I have tried the xtk:workflow Spawn method, however whilst this creates a new workflow from a template, it also starts the workflow. I could set the workflow template up to have a disabled start activity, and this does work, however it also creates workflow logs which seems to be a bit of a hack.

Ideally, I want to replicate the functionality of the console, where a new workflow can be automatically associated to a campaign:

1840254_pastedImage_0.png