The Gen2 canvas
decision task replaces many of the functions that were handled by the
evaluation task in the Gen1 canvas. With the workflow path in Gen2 being linear, the
decision task is used to create branches to validate the information (logic) that goes into it. Whereas the
evaluation task in Gen1 evaluated all of the branches together in unison, the
decision task in Gen2 will evaluate the logic within each branch serially until a passing condition is met. A successful evaluation will resolve the
decision task and allow the workflow to progress along the correlated branch. With that being the case, an output value is returned only when the decision logic (evaluation) passes as successful. Any failure or error that occurs will be handled by the Failure Handler or the Error Handler.
For more information on Failure or Error Handlers see the Gen2 Automation Builder user guide.
Potential Use Case
If you want to validate if certain variables exist within a dataset, you can use the
decision task to build branches within your workflow as a means to identify the variables you are looking for and then filter them out from the variables you do not want. With the
decision task, you can successfully verify if the specified variables are contained within the dataset or not.
Input and output properties are shown below.
||string||Yes||The job reference (id).|
||string||Yes||Specifies one or more conditions to be evaluated in a workflow decision.|
||string||The value returned when the decision task is called. In Gen2, the id of the next task to process.|
In this example, the
restCall task at the top of the workflow is pointing to a public API named Deal Me A Card, which is an automated card dealing program. One card will be chosen from the deck and the
decision task Did I get a RED Card? will be looking for a Red Card as the condition for a successful completion. If a Black Card is chosen, the workflow will follow an alternate path based on the variables that were set in the
Figure 1: Decision Task
ViewData task has been used to create a default path called Red Card, and a branched path, called NoRedCard. Clicking on the
decision task will allow you to see both possible paths that the data can follow.
If a Red Card is dealt, validation will take the default path and be a success. You can specify the default path by clicking the gear icon in the upper-right corner of the task card.
Figure 2: Decision Paths
Once the workflow has run, open the Job Details page in Job Manager and click the Work Task button to verify the correct routing of the variables in the workflow. In this example, the result is a
Success showing that a Red Card was dealt, the suit it was from (Hearts), and that all conditions in the default path passed.
After clicking the YAY! button the workflow will show as complete on the Job Details page.
Figure 3: Red Card Decision Path
If a Black Card is dealt, the
decision task will use the variables set in the
ViewData task named NoRedCard. In this path, the HEARTS and DIAMONDS will be singled out from the other cards and not evaluated as Red Cards.
Figure 4: No Red Card Decision Path
If no HEARTS or DIAMONDS are found when a card is dealt, the
decision task will then direct the decision path forward if there is a SPADE or CLUB. Once you click the Work Task button on the Job Details page in Job Manager, the results will show that
No Red Card was found in the suit (Spades).
After clicking the RATS! button you will be able to complete the workflow. In this case, you may end the automation or use a Failure Handler with another task to analyze the findings.
Figure 5: No Red Card Results