Using a globalMap variable in a map
Configure your Job to use globalMap variables in different components.
Procedure
- In your Job, add a tLoop component under the tHMap and link the tHMap to the tLoop with a Trigger > On Component Ok connection.
-
Next to the tLoop, add the following components:
- A tHttpRequest
- A tHMap
- A tLogRow
-
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:
-
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. -
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.
-
Double-click the tLogRow and define the following
schema:
Column Type page Integer character String character_id Integer -
Double-click the tHMap component to generate the
map.
- In the first step, select Select an existing hierarchical mapper structure and click Next, then select the structure you created from the API.
- In the second step, keep the default option and click Next, then click Finish.
The map is created, you can now configure it. - Drag and drop the input results/uuid element to the output character_id element and the input results/name to the output character.
- Drag and drop a GetValueFromExternalMap function to the output page element and add a Constant function on the Key argument.
-
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.
- Open the Run tab and click Run to run the Job.
Results
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 – please let us know!