For Each

Learn how to use the For Each activity in PopFlow for BUI.

Last published on: March 1st, 2022

The ForEach activity allows you to iterate over a list of items and process each item in turn. 

image

After opening the 'If' activity, you will get the below configuration panel. 

image

Default Configuration Parameters

Field Description
Each Item Single data of results.
Result Set The data to be iterated.

Sample For Each Activity

  • To configure a 'For Each' activity first you need to get the data from 'GET Activity', 'HTTPS Activity' or from any other source.
  • Once you get the data you can iterate on that data by using the 'For Each ' activity.
  • As an example of how this might be used. Assume you make an HTTP request that returns the following data:
{

          "page":1,"per_page":3,"total":12,"total_pages":4,"data":[

          {"id":1,"name":"cerulean","year":2000,"color":"#98B2D1","pantone_value":"15-4020"},

          {"id":2,"name":"fuchsia rose","year":2001,"color":"#C74375","pantone_value":"17-2031"},

          {"id":3,"name":"true red","year":2002,"color":"#BF1932","pantone_value":"19-1664"}
          ]
}
  • The brackets [ ] highlighted in red above indicate that this a list of items.
  • You can use the 'ForEach' activity to iterate through the list as shown in the following example:

image

  • After filling the values in the given fields you can close and save the activity by clicking outside of the activity.
  • You will notice two child buttons under the 'For Each' Activity.

image

  • 'After Each' button will contain single data of 'Result Set'.
  • 'On Finish' button activity will execute when the iteration of data is completed.