3.07 For Each Action Configuration
What is a For Each Action?
The
Creating For Each Actions
Click and drag the
icon from the toolbar onto the canvasEnter a name in the Create For Each Action window and select Create Action
In the
actionon the right, populate the following:
Field | Description | Example Value |
|---|---|---|
Input Expression | The input expression provides the source of the data to be iterated over. Typically, this will be a simple expression pointing at an Input Attribute, using the syntax, Connector.AttributeName. If an empty record set or empty list is provided then no output will be generated. This field is mandatory (PhixFlow version 11.1 +). | // Receives a list of Invoice IDs, these are iterated over using
|
Input Attributes | Attributes mapped into the For Each action will appear here. If adding a new input attribute, a Name and Type are required. See Understanding Data Types. | |
Output Attributes | Attributes mapped out of the For Each action will appear here. If adding a new output attribute, a Name, Type and Expression are required. This is a PhixScript expression. Values returned by the Input Expression are available in this expression as:
To work in a larger popup window, click See also: | Name: Type: Expression: |
Worked Example
Here's a worked example using the Company Data (available from the Learning Centre).
In this example, we are using:
A Company For Each Example screen containing:
an multi-line string field and Save button that will be used by the user to enter a list
a string field that will be used to create a filter
a grid backed by the ForEachExample table - this screen was created using the Multi-Tile template
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Advanced Application. For this example, we'll be working on the Company For Each Example screen.
Split a List Into Individual Records
In this example, we need a quick way to input a stock delivery into our application that can be processed later. We'll take a list of values inputted by a user and convert these into individual records.
Actionflow Setup
Open the Company For Each Example screen
Add an
to the Save buttonName:
SplitIntoRecords
Configure the Input as the CompanyForEachExample form
Map the attribute Text into the Actionflow
Calculate Action - Convert List to Array
Use the split function in a
Calculate Action - Create Session ID (Optional)
Create a SessionID attribute in a
For Each Action - Convert Array to Records
Use a
Create a
actionName:
Convert to Records
Connect it to the Calculate action and map across the Split attribute
On the For Each action, enter the following:
Input Expression:
in.SplitInput Attributes:
SplitCreate two Output Attributes:
Name:
NameType:
StringExpression:
trim(_result.value)The trim function is used here to remove the whitespace after the comma separator in the list
If this was not used and the list "one, two, three" was entered, the records "two" and "three" would be saved with prefixed whitespace
Name:
LastUpdatedType:
DatetimeExpression:
now()