The Loop through Table action is used to apply actions to a set number of records from a table.

For example: You have a table with names. You want to go through all the records in the table and update each name to ensure it has a Title case, i.e. is capitalized.

Parameters

▶  Select a table: an existing table in your Method account to loop through

▶  Where: the criteria builder will allow you to define a set of records of the table to loop through.

▶  Only distinct values from: only records with unique values in the selected field will be looped through.

▶  Order by: when looping through the table, you can set the order the loop is going through.

Criteria Builder

When you select Open criteria builder, a new page opens listing all the conditions.

Conditions are used to specify which records you want to loop through.

How do conditions work? When Method loops through the table, it will look at every record in the table, but only include records that match the given conditions.

The below example will loop through the table and go through every row with a Record ID greater than zero. Considering all records have a Record ID greater than zero, this, in effect, will go through every record in the table.

For more information, please visit our article on The Criteria Builder.

Embedding actions

  • Actions are embedded within the Loop Through Table action. This is indicated by indented actions marked by a blue line. In the below image, there are two actions inside of our Loop Through Grid action: Assign Value to Action Result action and Update Fields in Table action. The Show Message action is outside of the loop.
  • The Loop Through Table action will go through each record in sequence and applies all of its embedded actions to that row. 
  • To add a new action to the Loop Through Table action, hover over the action. The “” plus sign will add an action indented within the Loop Through Table action. You can also drag and drop other actions into the Loop Through Table action.
  • Actions embedded within the loop will have access to the data of each row. Note in the below example action, I can pull values from fields of the Loop.

Example

In this example, the action is set up to go through all the records in a table with a text field called Name. The Loop Through Table action is configured to go through all the records. 

Within the loop of the action are two other actions, Character Functions and Update Fields in Table. Note the vertical blue line which groups them together. 

Within Character Functions action, you need a way to grab the value of the Name field from the loop. Under the drop down Convert this to title case, there is a section called Loop. Underneath you will find all the field values of the current record within the loop, where we can select the Name field.  

And we will store the converted Name in an action result called resultNameTitled:

The next action will now update the name in the table we are looping through. The Update Fields in Table function will take the action result and update the Name field in the table.

The complicated part is setting up the criteria so the action knows which record to update. Going back to the Criteria Builder, you want the RecordID of the table to match the RecordID of the Loop. Notice the right dropdown now has a subset called Loop? Remember, this subset of fields only appears if the action is embedded in a loop. Make sure the proper RecordID fields are being compared.

Did this answer your question?