decision
  • 05 Dec 2024
  • Dark
    Light
  • PDF

decision

  • Dark
    Light
  • PDF

Article summary

Task Purpose

The new canvas decision task replaces many of the functions that were handled by the evaluation task in the GEN 1 canvas. With the workflow path in the new canvas being linear, the decision task is used to create branches to validate the information (logic) that goes into it. Whereas the evaluation task in GEN 1 evaluated all of the branches together in unison, the decision task in the new canvas 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.

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.

Properties

Input and output properties are shown below.

Incoming Type Required Description
job_id string Yes The job reference (id).
decisionArray string Yes Specifies one or more conditions to be evaluated in a workflow decision.

Outgoing Type Description
return_value string The value returned when the decision task is called. In Gen2, the id of the next task to process.

Example

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 decision task.

Figure 1: Decision Task

decision-ex01

A 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

decision-ex02

Once the workflow has run, open the Job Details in Jobs (Operations 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

decision-ex03

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

decision-ex04

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 Jobs, 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

decision-ex05


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.