Processing Chained Work Items — Web Service API Example

This topic provides an example that shows the web service calls from WorkItemManagementService that this sequence of events would produce. It uses the "WelcomeUsersChained" process, produced in the BPM tutorial "How to Ensure that a Sequence of Tasks is Performed by the Same User".

See also: WorkItemManagementService

First, use openWorkItem to open the first work item (workItemID 24) and assign it to a resource. The resource in this case is the user Clint Hill, with the ID 2D6430DC-9A65-4F21-A3BE-798AA192E468:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.wp.n2.tibco.com">
   <soapenv:Header/>
   <soapenv:Body>
      <api:baseWorkRequest>
         <resourceId>2D6430DC-9A65-4F21-A3BE-798AA192E468</resourceId>
         <workItem id="24">?</workItem>
         <workTypeDetail/>
      </api:baseWorkRequest>
   </soapenv:Body>
</soapenv:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <workResponse xmlns="http://api.wp.n2.tibco.com">
         <payloadModel payloadMode="JSON" xmlns="">
            <serializedPayload>{items:[{"$param":"UserName","$value":[],"type":"String","mode":"OUT"}]}</serializedPayload>
         </payloadModel>
         <workTypeDetail pilingLimit="0" typePiled="false" uid="WT__D1uKcCoHEeCmTZqrA21YZg" version="1.0.0.201108121142" xmlns=""/>
         <presentation activityName="GetUsersName" formIdentifier="1.0.0.201108121142/GIGWTPull_DefaultChannel/.default/ProcessPackage/WelcomeUsersChained/GetUsersName/GetUsersName.gwt.json" type="GWT_FORM" version="1.0.0.201108121142" xmlns=""/>
         <workItem id="24" version="1" xmlns=""/>
      </workResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Use completeWorkItem to complete work item 24:

oapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.wp.n2.tibco.com">
   <soapenv:Header/>
   <soapenv:Body>
      <api:workRequest>
         <resourceId>2D6430DC-9A65-4F21-A3BE-798AA192E468</resourceId>
         <workItem id="24">?</workItem>
         <workTypeDetail openNextPiled="true"/>
         <payloadDetails>
            <!--You have a CHOICE of the next 2 items at this level-->
            <serializedPayload>{items:[{"$param":"UserName","$value":[Filippo Scolari],"type":"String","mode":"OUT"}]}</serializedPayload>
            <XmlPayload/>
         </payloadDetails>
      </api:workRequest>
   </soapenv:Body>
</soapenv:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <workResponse xmlns="http://api.wp.n2.tibco.com">
         <payloadModel payloadMode="" xmlns=""/>
         <workTypeDetail pilingLimit="0" typePiled="false" uid="WT__efo_sClUEeCJP69W825hSw" version="1.0.0.201108121142" xmlns=""/>
         <presentation activityName="SendOutWelcomePack" formIdentifier="1.0.0.201108121142/GIGWTPull_DefaultChannel/.default/ProcessPackage/WelcomeUsersChained/SendOutWelcomePack/SendOutWelcomePack.gwt.json" type="GWT_FORM" version="1.0.0.201108121142" xmlns=""/>
         <workItem id="25" version="1" xmlns=""/>
      </workResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Use completeWorkItem again to complete work item 25:

 <api:baseWorkRequest>
         <resourceId>2D6430DC-9A65-4F21-A3BE-798AA192E468</resourceId>
         <workItem id="25">?</workItem>
         <workTypeDetail/>
</api:baseWorkRequest>
<workResponse xmlns="http://api.wp.n2.tibco.com">
         <payloadModel payloadMode="JSON" xmlns="">
            <serializedPayload>{items:[{"$param":"UserName","$value":[],"type":"String","mode":"OUT"}]}</serializedPayload>
         </payloadModel>
         <workTypeDetail pilingLimit="0" typePiled="false" uid="WT__D1uKcCoHEeCmTZqrA21YZg" version="1.0.0.201108121142" xmlns=""/>
         <presentation activityName="MakeFollowUpCall" formIdentifier="1.0.0.201108121142/GIGWTPull_DefaultChannel/.default/ProcessPackage/WelcomeUsersChained/GetUsersName/GetUsersName.gwt.json" type="GWT_FORM" version="1.0.0.201108121142" xmlns=""/>
         <workItem id="26" version="1" xmlns=""/>
      </workResponse>

Call completeWorkItem again to complete work item 26. This time the response shows no chained work item information.

 <api:workRequest>
  <resourceId>2D6430DC-9A65-4F21-A3BE-798AA192E468</resourceId>
         <workItem id="26">?</workItem>
         <workTypeDetail openNextPiled="true"/>
         <payloadDetails>          <serializedPayload>[]}</serializedPayload>
            <XmlPayload/>
         </payloadDetails>
      </api:workRequest>
 <workResponse isSuccessful="true" xmlns="http://api.wp.n2.tibco.com"/>