Outputting Data Objects From Rule Steps

Last Updated: 12/10/2018 Introduced in Version: 2.0

Rule Steps can be configured to return data objects rather than simple outcomes. For example, you can create a rule that outputs an account object that can then be displayed in a form.

In the Properties panel of the Rule Designer, in the Flow Data section, next to the Flow Input Data box, click the Add button to open a form for defining that rule’s output as the individual type or list of your choosing.

To create a data outcome rather than multiple path outcomes, in the Properties panel, in the Output section, in the Rule Type drop-down list, select Data Return Rule.

Map that output to a form’s input using the Mapping Editor.

Example

Our example flow will display a form that accepts a username and a value for years of experience. Based on the values we submit, our flow will then open a form displaying user information.

Rather than displaying information for every user in the system, our example flow will only display information for two new users. If, in our first form, we enter a value greater than 3 for years of experience, our flow will display information for the new user “Rahul.” If we enter a value less than or equal to three, our flow will display information for the new user “Amol.”

Many of the steps in the flow have been created for this example, including the form in which we enter data, and the form that displays the results.

 

2016-12-20_121659

 

We’ll begin our flow with many of our steps already in place. Our first step [Form] User Info displays our first form. Parse Number parses the “Years of Experience” value from our first form and ensures that the value is an integer. Get All 1 gets all user accounts from our system.

The last step of our flow [Form] Display Data  will display the details of the user account objects that our missing rule step will output.

 

2016-12-20_123337

 

To create our rule step, in the Components panel, in the Rule category, we will drag a [Pick Or Create Rule Step] component to the workspace. Once it is placed, we will click the link Pick or Create Rule from the Properties panel.

 

2016-12-20_130959

 

We will give our rule a name and click OK.

 

2016-12-20_131057

 

Next, we will build our rule. We’ll begin by defining a data type for the flow input, which sets the type of data that the rule’s conditions will evaluate.

In the Start Rule window, in the Rule Data section, next to the Rule Data Input box, we will click the Add New.

 

2016-12-20_131141 
 

Then, we’ll enter a name for the input, and click the Type selector.

We will select an integer data type (“Int32”) and click Ok.

 

2016-12-20_131255

 

Back in the Edit object pop-up, we save the input data by clicking Save.

To begin adding conditions to the rule, we select Add New Rule Step from the menu.

 

2016-12-20_131455 
 

Since the rule has only one condition, it will be fairly simple to build. In the Text Rule View tab, we will build the condition: “If Exp Greater Than 3”, where “Exp” will be the parsed “Years of Experience” from our first form.

We select Exp [Int32] and click Next.

 

2016-12-20_131551

 

We expand Number Rules, click Greater Than, and click Next.

 

2016-12-20_131629

 

Finally, on the Inputs step, with a mapping type of Constant, we enter “3” in the Value field and click Close.

 

2016-12-20_131702

 
 

Rule 1, as we’ve created it so far, will now generate two outcome paths “True” or “False” depending on whether the integer it is evaluating is greater than 3 or not.

If we wanted those outcomes to lead to significantly different steps, we might save Rule 1 as it is. However, we want Rule 1 to lead to the same step, just with different data. Our requirements state that the integer entered on a form should be evaluated, and then the resulting form should display an account object.

To create a data outcome rather than multiple path outcomes, in the Properties panel, in the Output section, in the Rule Type sections list, we select Data Return Rule.

 

2016-12-20_131923 
 

This reveals controls that we can use to define a data output for our rule. By default, the Output Type is still “Boolean.” We want Rule 1 to output an Account object for display in [Form] Form 1. To do this, we will click the Output Type selector.

 

2016-12-20_132010

 
 

The resulting pop-up allows us to navigate through all of the data structures in our system and select the one that’s right for our purpose. We will find Account then click OK.

 

2016-12-20_132052

 

Next, we need to define the two new user accounts that will be returned, depending on Rule 1’s outcome.

In the Text Rule View, click (Add) to the right from the Return step in Then section. Next, from the Mapping Type drop-down list, we select Constant . . .

 
2016-12-20_132210

 

. . . then click the Value selector.

 

2016-12-20_132308
 
 

We enter an EmailAddress and EntityName and click Save, first entering a new Account object belonging to “Amol”

 

2016-12-20_132500

 

then one for “Rahul.”

 

2016-12-20_132654

 

This completes our rule. After we’ve saved it and closed the Rule Designer, we can continue in the Flow Designer.

When we connect the rest of our paths, we’ll notice that Rule 1 has only one outcome path  Done rather than the True and False paths we would see for a simple rule. This is the path along which one of the Account objects we created in Rule 1 will pass.

Once our paths are all connected, we will select Rule 1 and click the Edit Input Mapping link in the Properties panel to complete the mappings for Rule 1.

 

2016-12-20_132931

 

Rule 1 expects the numeric input Exp, which we defined in the Rule Designer. To map it, we will drag and drop the anchor for ParseNumber_Output to Exp, and click OK to exit the Mapping Editor.

 

2016-12-20_133129

We’ll also want to map the input for [Form] Form 1, so we’ll select it and click the Show Mapping Editor link.

 

2016-12-20_133235

 

Because we want the form to display details about whichever Account object is outputted by Rule 1, we will map Rule 1 ‘s Result to the first item (Item 0) in the input collection account, then click OK to exit the Mapping Editor.

 

2016-12-20_133430

 

This completes our flow, so we save it and run it in the Debugger.

We’re presented with a form into which we can enter “Name” and “Years of Experience.” When we enter “4” years of experience

 

2016-12-20_133618

 

 

we’re presented with a form containing details of a new user account belonging to Rahul.

 

 

 

 2016-12-20_133930

We’ll click the Diagram tab to view the flow’s execution.

 

2016-12-20_133809

 

If we enter a number less than three for “Years of Experience”, such as “1”

 

2016-12-20_133858

 

we’re presented with a form containing details of a new user account belonging to Amol.

2016-12-20_133713

 

 

 

 

Additional Resources