LCS - Conditionals in Actions

Conditional steps in an Action are the decision points where two or more options are available and a set of conditional criteria are used to determine which option path is followed through the Action steps.

A conditional action step is used to create the logic which determines which of two or more options in an action path will be followed. The Action builder creates a drag-and-drop interface with a series of configuration steps to make this logic happen inside the platform.

Any piece of data contained in a data model property, passed into the action through a variable, or calculated in the action itself can be used in the decision-making process of the conditional action step.  The only critical parts about this data element are that it is contained in a variable, and that you can test the value in the variable using a condition like greater than, less than, equal or not equal to some other value.  The second value can also be a variable, or it can be a constant like today's date or the number 42.

In this example, you will be building a long-range weather prediction application based on whether a groundhog sees his shadow or not. 

Create An Action

1. If you are not building a loop inside of an auto-generated action (one created by the platform as a result of your dragging and dropping web components onto the canvas) you can create a new action using the button in the upper right of the Action panel on the left side of the interface:

The create new action button ( ) used to create a new action.

2. Your empty action will be created after you give it a useful name in the action creation dialog:

The empty action after initial creation

Create The Start Variables

For the purposes of this tutorial, there will be two variables in the Start action step.  One will be an input variable - the observation checkbox SeeShadow that will reflect one of two possible conditions - that the groundhog sees his shadow or he does not.  The other variable will be a daily record from the LongTermForecast model named GroundhogDay for today's long-term prediction, which for the purposes of this tutorial will be updated on February 2 of each year.  

  1. Click on the Start action step to open the configuration panel at the right.  
  2. In the Input Variables tab, click on the Add button, then add the details for the input checkbox variable called SeeShadow. The True or False value for this variable will be passed to the action in the calling step from the web form.
  3. Be sure to click on the Save button in the lower-right corner of the configuration panel to save your changes.
    The completed configuration is shown in this screenshot:

  The configuration for the input variable.

  1. In the Action variables tab, click on the Add, then configure a record variable to retrieve today's data from the LongRangeForecast data model.  That completed configuration is shown in this screenshot:The completed configuration of the Action variable for the LongTermForecast record.

Create The Condition Action Step

  1. Drag the Condition action step from the left pane onto the spinner between the Start and Finish action steps, dropping it on the spinner that appears between those two steps while you are dragging it onto the canvas.
  2. Your action path should look like the following:

The partially complete action path containing the Condition step.

Create The Condition Paths

  1. Click on the Condition action step to open the Condition configuration panel at the right of the screen.
  2. Rename the Condition by clicking on the placeholder title at the top of the configuration panel.  Change the name to something appropriate for the conditional test, like "Groundhog Sees Shadow?"
  3. Next, update the Condition action step by renaming Path 1 to "Yes - Six More Weeks Of Winter".  This will be the path that is followed if the checkbox is true, or checked. Note that renaming this path is not required, but it is helpful to you and the next person who is trying to follow the logic of your configuration.
  4. Rename the last path "No - Early Spring" which will be the one followed if the checkbox is false or unchecked.
  5. There are two paths in this simple example, one for true, the other false.  These are the only two states a checkbox field can be in. The number of paths in your business process may have two or more possibilities, in which case you should add one path for each possibility plus a final path to handle any set of circumstances that fall outside of the expected states. 
  6. If your business case does require more than two paths, you can add another path to the branching logic using the Add Path button. Note that each of your paths should also have a unique and mutually exclusive filter rule so that it is not possible for there to be more than one correct path through the action. If by mistake multiple paths are possible, the first path that evaluates to true from top to bottom in the list will be followed. 

Create The Filter Rule

  1. Click on the Add Filter Rule under Yes - Six More Weeks Of Winter and add a filter to determine if the SeeShadow checkbox was checked. This is a simple check, but you can add more rules or a more complex evaluation as your business requirements suggest. These filter rules are the second critical component of Condition configuration, after creating the paths themselves.
  2. You will need to complete a filter rule for each of your paths except the last path, which will handle anything that isn't logically covered by the possibilities that come before it in the condition paths.
  3. The completed configuration for this is shown here:

The completed configuration of the Condition action step.

4. Make sure you save all of your changes, then click on the X in the upper right corner to close the configuration pane.

Add An Action To The Conditional Paths

  1. After determining how many paths there are in your logic, you will need to specify what happens on each of those paths, including what happens on the final path, if anything, when none of the other conditions are met.
  2. Drag an Update action to each path of the Condition action step. In this example, the Prediction property in the record will be updated to one of two specifc values - "Six more weeks of winter" or "Early spring."  
  3. In the Update action for the Six more weeks of winter path, set the Prediction property of the GroundhogDay record to the value "Six More Weeks of Winter".
  4. In the Update action for the Early spring path, set the Prediction property of the GroundhogDay record to the value "Early Spring".
  5. Save all of your changes, then test your action to make sure it works as intended.
  6. Your completed configuration for the Update action in the Six More Weeks Of Winter path will look like the following:

The Update configuration for the Six More Weeks Of Winter leg.

The completed action path should look like the following:

The completed action path configuration.



Keywordsaction, if-then, conditional, logic   Doc ID135260
OwnerJeanne H.GroupLow Code Solutions
Created2024-02-06 15:03:19Updated2024-02-14 15:13:11
SitesDoIT Enterprise Business Systems - Low Code Solutions
Feedback  0   0