Repeating Workflow Tickets

An earlier example showed how to retrieve a copy of one document, render it to PDF and then save the rendition to the source document. Repeating workflow job tickets allow for the case where a business service returns a list of items that can be processed by subsequent business services.

The following example retrieves the documents in a Documentum folder, renders them to PDF and then adds the renditions back to the source documents. This job ticket shows the state of the job ticket after “retrieve” has been executed. The “documents” parameter contains the list of retrieved documents.

<workflow name="Test" submitter="John" product="Vista">
<retrieve>
<request tag="request1" name="retrieve-documents">
<folder-URL type="string">dms://dctm/borg/09015bda800081db?type=2</folder-
URL>
<documents type="xml">
<files>
<file>
<URL>dms://dctm/borg/09015bda800181db?label=CURRENT</URL>
<local-path>c:\temp\aaa1.tmp.doc</local-path>
<content-type>doc</content-type>
</file>
<file>
<URL>dms://dctm/borg/09015bda800182db?label=CURRENT</URL>
<local-path>c:\temp\aaa2.tmp.doc</local-path>
<content-type>doc</content-type>
</file>
</files>
</documents>
</request>
</retrieve>
<workflow for-each-item="retrieve/request[@tag='request1']/documents/files">
<render>
<request tag="request2" name="render-pdf">
<document-name
type="string" from-item="URL"></document-name>
<local-path type="string" from-item="local-path"></local-path>
<force-rendition type="bool">1</force-rendition>
<content-type>doc</content-type>
<rendition-found type="bool">0</rendition-found>
</request>
</render>
<distribute>
<request tag="request3" name="distribute-rendition">
<URL type="string" from-item="URL"></URL>
<local-path type="string"
from="render/request[@tag='request2']/local-rendition-path">
</local-path>
<format type="string">pdf</format>
</request>
</distribute>
</workflow>
</workflow>

In this example, “retrieve” has returned a list of two retrieved documents. However, “render” and “distribute” can only operate on one file at a time. The solution is to use a subordinate workflow with the “for-each-item” option. The “for-each-item” attribute value is the XPath reference to the parent node of the items (in this case “files” which is the value of the retrieve “documents” output parameter). This option allows the business services in the workflow to be repeated for each item in the list. Parameters in the repeated workflow have access to the current list item via the “from-item” attribute. The “from-item” attribute value is an XPath reference that is relative to the item’s node (in this case “file”). The “render” business service needs the local path from the list so the XPath is simply “local-path”.

By default, the “for-each-item” option executes each subordinate workflow sequentially. If you wanted subordinate workflows to execute concurrently then you can specify the “for-each” option as “do-concurrent” as follows:

<workflow name="Test" submitter="John" product="Vista">
<retrieve>
<request tag="request1" name="retrieve-documents">
<folder-URL type="string">dms://dctm/borg/09015bda800081db?type=2 </folder-
URL>
<documents type="xml">
<files>
<file>
<URL>dms://dctm/borg/09015bda800181db?label=CURRENT</URL>
<local-path>c:\temp\aaa1.tmp.doc</local-path>
<content-type>doc</content-type>
</file>
<file>
<URL>dms://dctm/borg/09015bda800182db?label=CURRENT</URL>
<local-path>c:\temp\aaa2.tmp.doc</local-path>
<content-type>doc</content-type>
</file>
</files>
</documents>
</request>
</retrieve>
<workflow for-each-item="retrieve/request[@tag='request1']/documents/files"
for-each="do-concurrent">
<render>
<request tag="request2" name="render-pdf">
<document-name
type="string" from-item="URL"></document-name>
<local-path type="string" from-item="local-path"></local-path>
<force-rendition type="bool">1</force-rendition>
<content-type>doc</content-type>
<rendition-found type="bool">0</rendition-found>
</request>
</render>
<distribute>
<request tag="request3" name="distribute-rendition">
<URL type="string" from-item="URL"></URL>
<local-path type="string"
from="render/request[@tag='request2']/local-rendition-path">
</local-path>
<format type="string">pdf</format>
</request>
</distribute>
</workflow>
</workflow>

The “for-each” option may be “do-concurrent” or “do-sequential”. If the option is not specified then “do-sequential” is assumed. If doing concurrently, then subordinate workflows will be submitted as separate jobs and the original workflow job will not wait for their completion/failure. Note that this means subordinate workflow jobs will show up in Domain Manager as separate jobs.