Skip to content
background-image background-image

Local Variables

Local variables are used to store data specific to a single task execution. They can be initialized with a starting value and then updated or referenced as the task runs. Each task keeps its own set of local variables, ensuring that the data is kept separate from other task executions.

Local variables can either be dynamically populated with data from the results of task steps or manually set with predefined values. This flexibility makes them useful for both automated data handling and customized setups. Click here for more information about the Local Variables feature.

Create your own example using local variables in a way that best fits your understanding. For a more in-depth look at how to work with local variables in tasks, you can explore the detailed text tutorial below, complete with images for guidance. Alternatively, if you prefer a more interactive learning experience, check out our video tutorial on the YouTube channel.

Where could we use local variables? For example, we can use them to retrieve a token. Let's say we're logging into a website, we obtain a token, and then in subsequent steps, since we already know the user's token, we can perform actions on the website under their token—essentially operating behind the scenes, beyond the login process.


Configuration

Add a first Task step:

  • Connector: Advanced Rest API Connector
  • Connector action: JSON

Fill in the Advanced Rest API - Data Endpoint configuration fields:

  • Endpoint - Endpoint URL path
  • Timeout - 100
  • Request type - POST
  • Data Content Type - JSON
    {"UserName":"user.name","Password":"password","Remember":false,"GRecaptchaResponse":null}
    
  • Error response behavior type - select from the dropdown list

Save the configuration.

Fill in the Advanced Rest API - Connection configuration fields:

  • Base URL - base URL
  • Authorization - None

Save the configuration.

HELP_ExampleLibrary_LocalVariables_FirstStep

Retrieving a token and inserting its content into the Token Value in the output schema.

Add a second Task step:

  • Connector: JSON Parser

Open the Task step editor. Select the Input schema JSON. Create a new custom output schema and name it Retrieving Token. Add a new column, Token, with the string data type and nullable value. Pin the input mapping.

Fill in the JSON Format configuration fields, creating the output schema mapping key:

  • Key - Token
  • Value - Token

Save the configuration.

HELP_ExampleLibrary_LocalVariables_SecondStep

Add a third Task step:

  • Connector: Advanced Rest API Connector
  • Connector action: JSON

Fill in the Advanced Rest API - Data Endpoint configuration fields:

  • Endpoint - Endpoint URL path
  • Timeout - 100
  • Request type - POST
  • Data Content Type - JSON
    {"DateFormat":"dd.mm.yyyy","TimeFormat":"12h","ShowDateTimeUTC":false}
    
  • Error response behavior type - select from the dropdown list

Save the configuration.

Fill in the Advanced Rest API - Connection configuration fields:

  • Base URL - Base URL
  • Authorization - Token
  • Token - ${LocalVariable.Token}

Save the configuration.

HELP_ExampleLibrary_LocalVariables_ThirdStep

Now, let's fill in the Local Variables. Create a new custom schema and name it Token. Add a new column, Token, with the string data type and nullable value. Use this schema for Local Variables.

HELP_ExampleLibrary_LocalVariables_Schema

You can see that the value in the schema is empty, but that's not important, we will fill it in our task. Click on Local Variables in the second step and map the value that comes from the JSON Parser to the Local Variables schema.

HELP_ExampleLibrary_LocalVariables_SecondStepLocalVariablesSchema

Great! The task is created; now, all that's left is to publish it and run it.


Result

As a result, we have a successfully completed task.

HELP_ExampleLibrary_LocalVariables_TaskFinishedSuccess

Let's open the Data Snapshot.

HELP_ExampleLibrary_LocalVariables_Dataviewer

As you can see, we received "Request successful." The server has responded as required.

Open Local Variables in the second step, and we will see that the Token field is filled with the Token value.

HELP_ExampleLibrary_LocalVariables_TokenValue


The use of local variables allows task-specific data to be dynamically stored and applied, enabling seamless and universal integration of the entire system. That's all from this example.