What are Loop Actions?
Image RemovedAdvanced Actionflow Settings
Additional options can be found in the Advanced section of certain action node
Insert excerpt |
---|
| _actionproperty_loopsettings |
---|
| _actionproperty_loopsettings |
---|
name | loop |
---|
nopanel | true |
---|
|
actions repeat an action or set of actions multiple times. In PhixFlow, there are three types of supported looping:
Advanced
Prioritise throughput over ordering
When enabled, records are processed in parallel to optimise performance. This means the order records are processed is nondeterministic.
When disabled (default), records are processed in the order they are provided.
Available on the following actions:
Section |
---|
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Section |
---|
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Section |
---|
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Section |
---|
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Column |
---|
Image Removed |
Section |
---|
Column |
---|
Image Removed |
Allow Parallel Runs from One Client
and in the Properties for the Actionflow itself, as specified below.
Allow Parallel Runs from One Client
This setting is available in the Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
for the Actionflow.
When enabled, allows an Actionflow to be run multiple times in parallel from the same client, i.e. another run can be started while the previous run is still being processed.
This option is disabled by default.
Advanced Settings - Node specific
Connection Timeout (s) | The maximum time to wait to while attempting to create a connection, measured in seconds. The default for this is set to 300 seconds. |
Response Packet Timeout (s) | The maximum time to wait between responses from the data packets, measured in seconds. The default for this is set to 180 seconds. |
Start Loop and End Loop
Loops consist of a Image Added
Prioritise Throughput Over Ordering
This setting is available in the Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
for the Actionflow and the action nodes, as specified below.
When enabled, records are processed in parallel to optimise performance. This means the order records are processed is nondeterministic.
Image Added
When disabled (default), records are processed in the order they are provided.
This option is available on the following actions:
actionloopstartactionloopstart and an loopendloopendOn the ,joined by a loop connector which returns the result of the End node back to the Start node. The Start and End Loop each have their own properties.loop_endloop_end, the Records to output can be set, either outputting All Records from the loop or just the Final Record. The icon on the end loop node shows which option is set.Image Removed
Loop Mappings
Attributes passed into a loop are available as passthrough, as well as attributes mapped in from the End Loop. This allows the original passthrough values to be referenced and if the loop is manipulating the incoming attributes, for example, incrementing a number, this is also available.
The mapped attributes that are manipulated by the loop are shown with a loop icon on the Mappings window, and passthrough attributes are shown with the icon of where they have come from, for example, a Insert excerpt |
---|
| _action_calculate |
---|
| _action_calculate |
---|
nopanel | true |
---|
|
|
|
calculatecalculateImage Removed
Tip |
---|
Loops wait until all their internal nodes have completed their tasks before beginning the next iteration of the loop. |
Creating Loop Actions
Click and drag the action. Insert excerpt |
---|
| _delete |
---|
| _delete |
---|
nopanel | true |
---|
|
|
|
looploopname | loop |
icon from the toolbar onto the canvasIn the Create Loop Action window:- Enter a Name
- Select Create Action
Map attributes from other actions to the
Column |
---|
Insert excerpt |
---|
| _action_for_each |
---|
| _action_for_each |
---|
nopanel | true |
---|
|
|
|
loop_startloop_startOn the to be processed by the looploop_endloop_end, set:- Records to output: Choose whether to output all records from the loop or just the final record
- Until Expression: An expression that is checked on each cycle of the loop, and once the expression returns true, the loop will end
- Example:
in.myValue == 10
- Max Loops: This is a safety net designed to stop infinite loops. After the number of loops set here, the loops will stop
- This default to 10000
Worked Example
Here's a worked example using the Company Data (available from the Learning Centre).
In this example, we are using:
- A Company Bank Holiday API - Loops screen containing a grid backed by an empty Bank_Holiday_Results table, drop down fields for the user to select the Year From and Year To values and a Run button - this screen was created using the Tile no Buttons template
Tip |
---|
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 Bank Holiday API - Loops screen. |
Loop Through Selected Years and Return Bank Holidays
In this example, a user selects two year parameters to obtains the UK bank holidays for. We'll create an Actionflow that takes in these two parameters and loops through each year. For the purposes of this example, our Actionflow will call an API that exists within PhixFlow but this API represents an external API.
Image Removed
Obtain the API URL
We have provided an Actionflow that acts as a UK Bank Holiday API. This can be called by a Actionflow, in the same way that an external API can be called. The UK Bank Holiday API has been configured to receive a year parameter and use that parameter to pass out the bank holiday dates for the corresponding year.
See 3.01 Setting up an API End Point for more details on how this API has been setup or to set one up yourself.
Search for the Bank Holiday API Actionflow on the Actionflow page- Image Removed
Open the Actionflow Insert excerpt |
---|
_property_settings | _property_settings | nopanel | true |
and in the API section, copy the URL and save it locally to be used laterActionflow Setup
Create an Actionflow using a Insert excerpt |
---|
| _action_json |
---|
| _action_json |
---|
nopanel | true |
---|
|
Insert excerpt |
---|
| _action_save |
---|
| _action_save |
---|
nopanel | true |
---|
|
Insert excerpt |
---|
| _action_xml |
---|
| _action_xml |
---|
nopanel | true |
---|
|
|
|
Advanced Settings - Action Node Specific
Insert excerpt |
---|
| Bulk Delete Action Configuration |
---|
| Bulk Delete Action Configuration |
---|
name | BatchSize |
---|
nopanel | true |
---|
|
Connection Timeout (s)
On the Insert excerpt |
---|
| _action_http |
---|
| _action_http |
---|
nopanel | true |
---|
|
action, in the Advanced section, a maximum time to wait while attempting to create a connection can be set, measured in seconds. The default is 300 seconds.
Response Packet Timeout (s)
On the
looploopname | action |
Select the Year From and Year To criteria and press Run to poll the API and retrieve the bank holidays for the years selected on the Company Bank Holidays API - Loops screen.- Open the Company Bank Holidays API - Loops screen
- Add an Actionflow to the Run button
- Name:
Get Bank Holidays
Testing
Close all screens and reopen the Company Bank Holidays API - Loops screen action, in the Advanced section, a maximum time to wait between responses from the data packets can be set, measured in seconds. The default is 180 seconds.
Image Modified