Note: The workflow sample mentioned in this article can be downloaded from the Opalis project on CodePlex: http://opalis.codeplex.com
A collection of Workflows that demonstrate how to trigger a Child Workflow, how to submit data to a Child Workflow and how to consume data from a Child Workflow. The Workflows also demonstrate synchronous and asynchronous behavior when triggering Workflows.
This Workflow uses the Trigger Workflow Activity to trigger Child Workflow ‘2. File Creation Child Workflow’ and submit two parameters:
As the ‘Wait for completion’ option is not used, the behavior of the trigger is Asynchronous. The parent Workflow does not wait for the Child Workflow to complete. The next two Activities demonstrate how to verify if the Child Workflow is ‘done’ by checking for the existence of a text file, and the existence of a string in the last line of that text file.
The Get File Status Activity ‘Wait for File to be Created’ loops every five seconds to check if the file ‘c:\filename.txt’ exists. The loop exits if the file is present:
The looping properties (right mouse click, Looping…) are as follows:
The Read Line Activity ‘Wait for Last Line’ loops every second to read the last line of the text file ‘filename.txt’. The loop exits if the string reads ‘THIS IS THE LAST LINE’:
Next, another Trigger Workflow Activity is used to trigger Workflow ‘3. File Deletion Child Workflow’ and submit the name and path of the file as a parameter:
As the ‘Wait for completion’ option is used, the behavior of the trigger is synchronous. The parent Workflow waits until the Child Workflow completes.
The Send Platform Event Activity displays the filename that was created, as well as data from the Child Workflow ‘3. File Deletion Child Workflow’: the number of files deleted.
This Workflow uses the Custom Start Activity to obtain input using two custom variables:
The Append Line Activity loops to add twenty lines to a text file. The text and filename originate from the Custom Start Activity. The second Append Line Activity adds the ‘THIS IS THE LAST LINE’ text to the file.
The first part of the Parent Workflow ‘1. Nested Workflows’ checks for the creation of the file and the addition of the ‘THIS IS THE LAST LINE’ text.
This Workflow performs cleanup by deleting the file created by the Workflow named ‘2. File Creation Child Workflow’. It uses the Custom Start Activity to obtain input using one variable: filename. The Delete File Activity then deletes the file. The Publish Workflow Data Activity published data from the Delete File Activity so that it becomes available to the Parent Workflow. This is accomplished by adding Workflow Data to the Child Workflow (Workflow properties):
The Publish Workflow Data Activity can then subscribe to the Published Data that is made available as ‘Number of Files Deleted’ to the Parent Workflow:
Launch the Workflow ‘1. Next Workflows’ by using Start or by running it using the Operator Console. Check the Opalis Designer Events tab or Operator Console log to see the resulting output.
Search the Opalis Online Help for 'Trigger Workflow', ‘Workflow Properties’ and ‘Publish Workflow Data’ for more information on nesting Workflows.