List Container Rules
- Updated on 20 May 2015
- 3 minutes to read
List Container Rules are implemented in Decisions in the Rule Engine. These Rules are designed to process a list of items and apply desirable conditions to each item in the list. The List Container Rules have the following three options:
- Contains All – Each item in the list should satisfy the condition for Rule to evaluate as True.
- Contains Any – At least one item in the list should satisfy the condition for Rule to evaluate as True.
- Does Not Contain Any – None of the items on the list should satisfy the condition for Rule to evaluate as True.
In this example, create a Rule that takes in an array of Accounts . It should evaluate as True if all Accounts in the array have Email Address that contains “decisions”. This example requires List Container Rules to test each Account in the array. Begin in the designer Folder by selecting the Create Rule option in the Folder Actions Panel. In the resulting window, Name the Rule (List Container Rule) and select Create to proceed to the Rule Designer.
In the Rule Designer , we click Show Editor link to add Rule Input Data.
Set up the Data by creating a name called Accounts . Next, select the Type by choosing All/Types and search for Accounts.
Next, after the Data Definition has a Name, select the Account Type. Check the Is List check box, this will make the definition an array that displays Contains All, Contains Any or Does not Contain Any . Then, we select close to save and begin setting up the Rule.
In the Rule designer, the Rule Input Data will not show Accounts in the show editor text box.
Begin by choosing Accounts in the Select Data Element (drop-down). In the next window we should be able to see List Container Rules category because Accounts variable is an array. We click Contains All option from the List Container Rules category because we want to check if all Emails contain “decisions” . Then, we click Next .
Choose Pick Verb, Contains All. In the next window, we should be able to see List Container Rules category because Accounts variable is an array. We click Contains All option from the List Container Rules category because we want to check if all Emails contain “decisions” . Then, we click Next .
Under Collection Information and Each List Item Name give the input a name to provide a Name for the Element in the array and select done. In this example the name provided is Email.
The List Container Rule is now complete. Selectclose to save the Rule.
To create conditions to check each item, select Add and then choose Add Condition. Each item passed through the Rule will need to pass the condition created. This condition will check to see if Account.EmailAddress contains "Decisions".
Expand the Email category (which is the Name for each element in the Array) and select the EmailAddress string, then, select Next .
In the following window, select Contains verb from the Text Rules category and choose Contains then selectNext to continue.
In the last window of the Rule Phrase Builder , set Mapping Type Constant with Value “decisions”. Select Done to save the Rule.
Our Rule is completed. We click Close to close Rule designer. To test our Rule we click Debug Rule on the top panel of the *Rule designer.*
Next, Create two Unit Tests for the Rule . Start by naming the first Unit Test Pass , leave Test Result to Pass and select Add New to add accounts to the Rule Input. This Unit Test only accounts that contain “decisions” in their Email Address. Select Save to save this Unit Test. In the same way, Create a second Unit Test called Fail and choose and email address that does not have "decisions.com" in the address and check the results.
This completes the List Container Rules example. For more information on creating Rules please see attached links: