Using a Rule to Return DataLast Updated: 08/09/2016 Introduced in Verision: 2.0 |
Rules evaluate a data input and typically return an outcome of true or false, depending on whether the input satisfies the rule’s conditions. Rules can also output data objects instead of a simple true or false value, depending on whether the rule is satisfied.
To make a rule output data instead of a simple true or false value, create your rule in the Rule Designer. Under the section Output, choose the Rule Type: Data Return Rule and click Add New Rule Step. A new Then Return, Else Return section will appear, containing two mappable properties – Outcome Data [True] and Outcome Data [False]. Use these properties to define the data objects to be returned in either case.
Example
Our example flow will use a rule to determine whether a given user is the Administrator. If the user provides the flow with an email that does not appear in the email address of the user running the flow, it will display a message stating that it is not an admin account. If the user provides the flow with an email address that appears in the email address of the user running the flow, it will display a message stating that it is an admin account.
This example assumes that the runner of the flow is always an Administrator –
Navigate to your Designer Project folder. From the Create Rule button, select Create Rule.
Give the new rule a name, “CheckEmailID” for example, and click OK.
In the Rule Designer, under the Rule Data section, click the Add New button.
Fill in the Name field with “EmailID”, make sure the Type is String and click OK to save.
Under the Output section, choose the Rule Type: Data Return Rule.
Click the Output Type selector and in the Pick Type popup, select String.
Because we only want to output one message, not several, leave the Is List checkbox cleared and click OK.
Click Add New Rule Step.
Because we want to evaluate the email address of the user running the flow against an email address that the user will input at runtime, select Flow Data [RuleConstantData] > InitializingUserEmail for the anchor variable and click Next.
Select EmailID and click OK.
Click Done to complete the Rule Step and close the Rule Step box.
Next, configure our rule to output a message instead of a simple true or false value. Click on Change in the Then statement next to Return [no mapping set] to map the Outcome Data [True]. Set the Mapping type as Constant, and in the Value field, fill in “This is an admin account”.
Then click on Change in the Then statement next to Else Return [no mapping set] to map the Outcome Data [False]. Set the Mapping type as Constant, and in the Value field, fill in “This is not an admin account”.
Save and close the rule.
To begin our flow, add the rule just created into the workspace. It can be found in the Flow Designer start-up window, under the category Flows, Rules, Forms and Reports > Rules > [Current Folder]. Click Add to add it to the workspace.
Next, connect the outcome paths of our flow.
Next select the form step – [Form] Display Admin Message – and click the Show Mapping Editor link at the top of the Properties panel. In the Mapping Editor, map our rule step’s output, Result, to our form step’s input, AdminMessage. Click OK to close the Mapping Editor.
To test our rule, open our flow in the debugger. First, compare the email
The two email accounts are the same and the message returned by our rule reads “This is an admin account.”
Next, test using a different email address. The message returned by our rule reads “This is not admin account.”