Skip to main content Skip to complementary content

Using a globalMap variable in a map

Configure your Job to use globalMap variables in different components.

Procedure

  1. In your Job, add a tLoop component under the tHMap and link the tHMap to the tLoop with a Trigger > On Component Ok connection.
  2. Next to the tLoop, add the following components:
    • A tHttpRequest
    • A tHMap
    • A tLogRow
  3. Link the tLoop to the tHttpRequest with a Row > Iterate connection, and link the other components with Row > Main connections.
    Your Job should look like this:
  4. Double-click the tLoop component and configure it as follows:
    Parameter Value
    Loop Type For
    From 1
    To (((java.math.BigInteger)globalMap.get("total.pages"))).intValue()
    Step 1
    This configuration allows you to define the end of the loop as the number of total pages in the API response. Since the total.pages variable created in the map is a BigInteger, you need to convert it to an Integer in order to use it as a value in the tLoop.
  5. Double-click the second tHttpRequest component and configure it as follows:
    Parameter Value
    URI "https://www.swapi.tech/api/people?page="+((Integer)globalMap.get("tLoop_1_CURRENT_VALUE"))+"&limit=10"
    Method GET

    This configuration allows you to use the value of the current loop as a page number in the request parameters.

  6. Double-click the tLogRow and define the following schema:
    Column Type
    page Integer
    character String
    character_id Integer
  7. Double-click the tHMap component to generate the map.
    1. In the first step, select Select an existing hierarchical mapper structure and click Next, then select the structure you created from the API.
    2. In the second step, keep the default option and click Next, then click Finish.
    The map is created, you can now configure it.
  8. Drag and drop the input results/uuid element to the output character_id element and the input results/name to the output character.
  9. Drag and drop a GetValueFromExternalMap function to the output page element and add a Constant function on the Key argument.
  10. Double-click the Constant function and enter tLoop_1_CURRENT_VALUE in the Value field.
    This will allows you to retrieve the value of the current loop from the tLoop component to get the page number for each result.
  11. Open the Run tab and click Run to run the Job.

Results

The result should look like this:

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!