Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
_Banners
_Banners
nameactionflow
nopaneltrue

What are Loop Actions?

Insert excerpt
_action_loop
_action_loop
nameloop
nopaneltrue
 actions repeat an action or set of actions multiple times. 

In PhixFlow, there are three types of supported looping:

Polling

Repeats the same operation multiple times with the same parameters, until a desired result is obtained.

  • Generates a single output record
    • Output results are only generated at the end of the iterations

  • Example: polling a HTTP API until the results are available

    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 Added


    Column

    Image Added


    Column

    Image Added



    Section


    Column

    Image Added


    Column

    Image Added


    Column

    Image Added



    Section


    Column

    Image Added


    Column

    Image Added


    Column

    Image Added



    Section


    Column

    Image Added


    Column

    Image Added


    Column

    Image Added




    Section


    Column

    Image Added



    Allow Parallel Runs from One Client

    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


    FieldDescription
    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

    Insert excerpt
    _action_loop_start
    _action_loop_start
    nopaneltrue
      and an 
    Insert excerpt
    _action_loop_end
    _action_loop_end
    nopaneltrue
    ,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.

    On the 

    Insert excerpt
    _action_loop_end
    _action_loop_end
    nopaneltrue
    , 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.

    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
    nopaneltrue
     action.

    Tip

    Loops wait until all their internal nodes have completed their tasks before beginning the next iteration of the loop.

    Creating Loop Actions

    1. Click and drag the 
      Insert excerpt
      _action_loop
      _action_loop
      nameloop
      nopaneltrue
       icon from the toolbar onto the canvas
    2. In the Create Loop Action window:
      1. Enter a Name
      2. Select Create Action
    3. Map attributes from other actions to the 
      Insert excerpt
      _action_loop_start
      _action_loop_start
      nopaneltrue
      to be processed by the loop
    4. On the 
      Insert excerpt
      _action_loop_end
      _action_loop_end
      nopaneltrue
      , set:
      1. Records to output: Choose whether to output all records from the loop or just the final record
      2. Until Expression: An expression that is checked on each cycle of the loop, and once the expression returns true, the loop will end
        1. Example: in.myValue == 10
      3. Max Loops: This is a safety net designed to stop infinite loops. After the number of loops set here, the loops will stop
        1.  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:  

    • 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.

    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.


    1. Search for the Bank Holiday API Actionflow on the Actionflow page
    2. Open the Actionflow
      Insert excerpt
      _property_settings
      _property_settings
      nopaneltrue
       
      and in the API section, copy the URL and save it locally to be used later

    Actionflow Setup

    Create an Actionflow using a

    Insert excerpt
    _action_loop
    _action_loop
    nameaction
    nopaneltrue
     to poll the API and retrieve the bank holidays for the years selected on the Company Bank Holidays API - Loops screen.

    1. Open the Company Bank Holidays API - Loops screen
    2. Add an Actionflow to the Run button
      1. Name: Get Bank Holidays


    Testing

    1. Close all screens and reopen the Company Bank Holidays API - Loops screen
    2. Select the Year From and Year To criteria and press Run