Rule Collection Sort Step
  • 22 Sep 2020
  • 1 Minute to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Rule Collection Sort Step

  • Dark
    Light

Article summary

Overview 

The Rule Collection Sort Step is a Flow step in the Flow Designer that can take in a list of any type, and sort the data based on the outcome of a rule. This step is an Array.sort(List, comparer) that takes in a list of items, and determines the comparer based on the evaluation of a rule. This rule can be configured by clicking the 'Edit Rule' underneath the 'Validate Flow Step' in the properties panel. Within the Rule Designer, there are settings that set it apart from creating a custom rule. For example, the 'Outcome Data' on the 'Result' and the 'Else' rule parts are configured for the 'RuleCollectionSortOutcome' Decisions Datatype. The 'RuleCollectionSortOutcome' data type has 3 constant mappings that return a different priority sort value based on the selection. The available selections are:

Function
Mapping Value Name
FirstEntitySortsFirstThe first item comes before the second one
SecondEntitySortFirstThe first item comes after second one
FirstAndSecondEntitySortSameSort priority is the same

Example

To see this step in action, create a 'Flow' and drag a 'Fetch Entities' step along with a 'Rule Collection Sort' Step. Connect all the steps together. On the Fetch entities step, select the 'Account' datatype and pass the 'All EmailAddress' to the 'Input Collection' of the 'Rule Collection Sort'.


Next, configure the sort rule on the 'Rule Collection Sort' step. This is accomplished by clicking the 'Edit Rule' button. In the rule designer, configure the rule to check if the first entity contains admin. Have the 'Result' outcome path set to 'FirstEntitySortsFirst' and the 'Else' outcome path set to 'SecondEntitySortFirst'. After this configuration save and close the rule.


Debug the Flow, and view the input/outputs on the rule collection sort. The inputs/outputs will show that The Rule Collection Sort step has correctly evaluated the rule because the admin email address is the first item in the sorted list.



Was this article helpful?