Lookups with Dynamic Parameters

Overview

Lookups can be configured with a variable (parameter) set as the Filter attribute, allowing the values sent to the filter to be set dynamically. For example, where two lookups are used and the results of the second lookup are determined by the first.  

Example use case

Retrieve all the emails addresses for people that work at a company that operates in the Telecoms industry.

Setup

  1. Create a Actionflow and add an input Parameter to the input connection point called Industry
  2. Add a Calculate e.g. Retrieve
  3. Add a lookup to the Calculate that returns a list of Company IDs
    1. Add CompanyID as the attribute to return.
    2. Map in the Industry attribute as a Request Mapping,
    3. Map CompanyID as the Return Mapping.
  4. Add a second lookup to the Calculate that returns the Employee Email attribute
    1. Add Email as the attribute to retrun.
    2. We will return to this and configure the mappings in a later step.
  5. Open the Calculate node's properties.
    1. In the Input Connections section, double click the name of the pipe connected to Employees.
    2. Add a Request Parameter called CompanyList and set its data type to be Structured Data
    3. This Request Parameter is now available to the Employee lookup.
  6. Click on the pipe connecting the Calculate to the Employees 
    1. Map CompanyList in as a Request Mapping
    2. Map Email out as a Return Mapping
  7. Click on the Employees View Node to open its properties
    1. Create the Filter, withe the following settings
      1. CompanyID
      2. is in
      3. CompanyList
  8. On the Calculate add an Output attribute
    1. Set its expression to be:
    2. // This uses the lookup() function to look at the emp pipe
      // and set the Request Parameter CompanyList to be the the list of 
      // CompanyIDs provided by the co lookup.
      
      lookup(emp, $CompanyList = co.CompanyID).Email
    3. Note the Request Parameter is populated by name, using a variable of the same name.
    4. For help on this function see lookup
  9.  Example Setup

    Click to enlarge

Testing

  1. Click  Run Action 
  2. Enter Telecoms as the Industry
  3. The results will show a list of email addresses.