Find and Select

Find

The Select and Find Actions are used to find objects by applying different conditions/filters on the fields of those objects. Each of these actions executes a query on the platform's underlying database; the Select action returns all the query results contained within a single collection, and the Find action returns one result at a time as a variable. This collection or variable is then accessible to other actions further in the logic chain of the Routine.

The Find action contains two flags:

Order Find Results

Order the fine results when the First element only flag is unselected.

  1. Create a new routine and add an action.
  2. Select Find Action Type.
  3. Choose object and object type.
  4. Ensure that the First Element Only check box is unselected.
  5. Select the value to order by from the Order By drop-down.
  6. Select the direction to order in. By default, the results are returned in ascending order. Check the Descending option to reverse the order.

Select

The Select action returns a single collection, "trailer_collect", containing all trailers with a speed greater than 50; further Routine logic only has access to the collection of trailers as a whole, not the individual objects themselves. The Find action, on the other hand, returns a single trailer matching the criteria as the "trailer" variable; the system will then loop the execution of the Routine such that everything within the "trailer found" conditional statement will be repeated for every trailer matching the criteria. So, if four trailers exist in the system with a speed more than 50, the Find example above would display the message "Trailer found" four times, and the Select example would display the message "Trailers found" once. Of course, if the "First Element Only" flag of the Find action is checked, the system will not loop any Routine logic, as the action will return at most one object. A user can easily tell when this flag is checked, as the action itself will appear different in the chain: instead of three lines connecting the action to the rest of the chain, there will only be one.

The Find and Select actions must be followed by an "If, Then, Else" action. For the Find action, the conditional statement uses the "If Variable is Defined" condition type with the name of the saved variable from the Find action itself, and for the Select action, it uses the "If Collection is not Empty" condition type with the name of the saved collection. This ensures that the system will not attempt to execute actions on the variable/collection if it is null, which would result in an error.