Caution
Test the script(s), processes and/or data file(s) thoroughly in a test environment, and customize them to meet the requirements of your organization before attempting to use it in a production capacity.  (See the legal notice here)

 

Note: The workflow sample mentioned in this article can be downloaded from the Opalis project on CodePlex:  http://opalis.codeplex.com

 

Overview

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.

 

Example Workflows

1. Nested Workflows

image

This Workflow uses the Trigger Workflow Activity to trigger Child Workflow ‘2. File Creation Child Workflow’ and submit two parameters:

image

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:

image

The looping properties (right mouse click, Looping…) are as follows:

image

image

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’:

image

The looping properties (right mouse click, Looping…) are as follows:

image

image

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:

image

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.


2. File Creation Child Workflow

image

This Workflow uses the Custom Start Activity to obtain input using two custom variables:

image

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.

 

3. File Deletion Child Workflow

image

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):

image

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:

image

Running the example 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.

More Information

Search the Opalis Online Help for 'Trigger Workflow', ‘Workflow Properties’ and ‘Publish Workflow Data’ for more information on nesting Workflows.

 

 

Share this post :