- 17 Feb 2020
- 4 Minutes to read
- Print
- DarkLight
Using Rule Steps in a Flow
- Updated on 17 Feb 2020
- 4 Minutes to read
- Print
- DarkLight
Overview
Rule Steps evaluate a data input and return an outcome of true or false. This outcome path depends on how the input satisfies the conditions, that the rule(s) contain. Rule Steps can contain entirely original rules, or preexisting rules as long as they have been saved in a folder that is visible to the user. Rule Steps can be found in the Steps Tab, under the category Rules.
Example
In this example, create a rule that evaluates all of the system's user accounts for the following three conditions:
- The Email address belongs to the "decisions.com" domain.
- The account status is active.
- The account has permission to use the portal.
The example flow will display a form that lists the email address.
Begin in a Designer Folder, select Create Flow from the bottom action panel.
From the Start step add a Get All step from Integrations > Internal Services > AccountService. This step will retrieve all Accounts.
On the GetAll outcome path add a ForEach step from the Flow Management category in the Steps panel.
Under Inputs > Collection choose Select From Flow as the mapping type and choose GetAll1_Output. Connect the Done outcome path to the End step.
On the ForEach step's Next outcome path add a [Pick or Create Rule] step from the Rules category in the Steps panel.
Under Advanced > Target select Create. In the Create New Rule dialog name the new rule and select Create.
The Rule Designer offers a simple but powerful interface for generating a data rule. A rule is a collection of one or more conditions that must be met in order for an input to be considered valid. Together, these conditions form a statement that closely resembles plain English.
Before creating the conditions of the rule, define the type of input that the rule can be applied to. At the top of the Rule Designer select Setup Input Data.
In the Data Definitions dialog, define the input data as an Account object, by searching for "Account" in the search box under Type, then select Account.
To evaluate each account individually, leave Is list unchecked. Leave Can be null unchecked as well. Select Close to save and close the Data Definitions dialog.
Next, define the conditions of the rule statement. Notice the rule statement has already been started with the word If. The Add button in this bracket indicates a point where a new condition can be included.
Every condition consists of three parts:
- Anchor data: the input property which will be compared
- An operator: the type of comparison being made
- A value against which the input property will be compared
The first condition of this rule is that the account's email address must contain "decisions.com."
For the anchor data, select the input Account > Email Address then, select Next.
The condition to evaluate is whether the email address in question contains "decisions.com," select the operator Text Rules > Contains and click Next.
The value we're comparing against is "decisions.com," so in the Inputs section of the next dialog, enter "decisions.com" in the Value field then click Close.
This completes the first condition. If we were to save this rule and use it as-is, only accounts with an email address containing "decisions.com" would be considered valid when inputted into this rule step.
Select the Add button following the first rule statement and select Add New Rule Step.
The next condition will evaluate if the account is active. Find the anchor for this property under Account > Archived then, select Next.
The Archived property type is a Boolean. For the operator, select Is True under Logic. Select Done. This completes the second condition.
Click on the Add button following the second rule statement and select Add New Rule Step.
The third and final condition will evaluate if the account has permission to access the portal. Find the anchor for this property under Account > CanUsePortal, then select Next.
Just as with the Archived property, CanUsePortal is a Boolean variable that can only be true or false. For the operator, select Is True under Logic. Select Done. This completes the third condition. Save and close the Rule Designer.
Back in the Flow Designer, map Item from the ForEach step into the Account input on the rule.
From the Rules False outcome path connect it to the ForEach step.
From the Rules True outcome path add an Add Item To List step from the Data > List category in the Steps panel.
Under Data > ListType select Account. Then under Inputs > New Item chose Select From Flow as the mapping type and chose Item. For Original List select New List.
Have the Done outcome path connect back to the ForEach step.
With the ForEach done path connected to the End step. On the End step under Data > Output select Show Editor. In the Data Definitions dialog, name the output "Valid Emails", leave the type as String, check the IsList box.
Under Inputs for Valid Emails choose Select From Flow and select NewList > EmailAddress.
Make sure all the outcome paths are connected. Select Debug in the top action panel.
When the flow runs in the debugger the rule evaluates six accounts, three accounts evaluate as true and are added to the list and passed to the end step.