Process Action Example Workflow

This example describes how to process files individually using a process action's "Command Properties" field. This example will also guide you through the steps of setting up a process action to run a program.

In the example, we'll create a file trigger that watches for .txt files in a specific directory. Once the files are found, they'll be passed into a for each collection element action that will iterate through each file, one at a time. As each file name is passed into the process action, it will be used as an argument for the process action's command. Once the list of files is exhausted, an else flow will complete the workflow.

Viewing the Example Files

Your Flux installation includes a working, pre-constructed version of this example. To load the example file:

  1. Click the "Repository" tab.
  2. Choose the "Workflows" option.
  3. Click the "Upload" button.

In the dialog that appears, browse to <Flux Home>/examples/end_users/process_action, and select the .ffc file located there.

When the workflow finishes uploading, select it from the grid and choose the "Edit" button to view the workflow in the Designer.

Navigating to the Designer

The Flux Designer will be used to create and execute the example workflow. To use the Designer, browse to the Operations Console and select the "Designer" tab.

       

Creating Actions

When you visit the Designer, you'll se a blank workspace representing the new workflow. To create the example, we'll start by populating the workflow with a few actions.

When you return to the Designer, you will see a blank workspace representing the new workflow. To create the example, you will need to populate the new workflow with a few actions.

To add an action to the workflow, you'll first need to select the action's category in the panel to the left of the workspace. Once you've selected the appropriate category, the action will appear in the panel – left-click the action and drag it onto the Designer workspace to add it to the workflow.

The following table contains the type, category, and quantity of each trigger and action we'll use in this example.

Action Type
Category
Quantity
File Exist Trigger File

1

Console Action Core 2
Process Action Core 1
For Each Collection Element Action Workflow 1

Setting up Flows

Using the image below as a guide, create flows between the actions. To create a flow:

  1. Click the connect button the Designer toolbar.


     
  2. Click and hold the left mouse button on the action you wish to draw the flow from.
  3. Drag your cursor to the action you wish to draw the flow to and release.

Now, we'll need to make some changes to perform data mapping to print our results, and to set up the else flow (shown in the image above).

  1. Right-click the flow from the for each action to the console action. Choose flow properties, and change the flow type to "ELSE".
  2. Right-click the flow from the file exist trigger to the for each action. Choose flow properties, add a runtime data map, and enter the following.
    1. In the top field, the data map source, enter "RESULT.file_name_matches".
    2. In the drop-down menu next to the bottom field (the target), select "Property of Next Action". 
    3. The right-hand field will change to a drop-down menu. Choose "Collection" from the menu.
  3. Repeat the process for the flow from the for each action to the console action.
    1. In the source field, enter "FILENAME".
    2. For the target, choose "Property of Next Action".
    3. In the drop-down menu, select "Message".
  4. Add a runtime data map to the flow from the console action to the process action.
    1. For the source, enter "FILENAME" again.
    2. For the target, set the type to  "Property of Next Action".
    3. Select the "Command Properties" option for the target. 

Editing Action Properties

 

File Exist Trigger

Double-click the trigger to open its action properties. Click the "+" icon next to the source. The criteria editor will appear:


 

Set the include pattern to the full path:

<Flux home>/examples/end_users/process_action/Files to be Processed/*.txt

For Each Collection Element Action

Set the loop index to "FILENAME". This property determines the name of the variable that will store the current element collection at runtime — when the action runs, it will place the current file into the variable "FILENAME".

Console Action

Set the "Message" property of the console action to read "Processing is complete".

Process Action

Finally, we'll need to configure the process action to run using the file names we pass in. Edit the command field to read "cmd /c ${FILENAME}". This will open the system command shell and run the file name passed in from the "FILENAME" variable.

Running the Workflow

Finally, click the "Export to Engine" button in the Designer. This will start the workflow.

Your workflow should now be running. If you watch the command prompt your engine is running on you will see the first name of the first file in the “Files to be Processed” directory. After the file name is displayed on your command prompt a “.txt” file will open on your machine. Edit this file if you wish, and then exit out. The workflow then moves onto the second file to be processed. The file name is printed out on your console and the file opens for editing. If you exit this file the same will happen with the next file. This behavior continues until all files have been processed in the specified directory, then the Else flow is followed and the workflow ends.

Once this example is completed, you can shutdown your server. If your PDF viewer does not support this hyperlink functionality, locate and run the “shut-down-unsecured-flux-engine” batch or shell file within your Flux installation directory, depending upon which platform you are running Flux on.

 
 
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.