News Stay informed about the latest enterprise technology news and product updates.

How to pass variables as UiPath arguments example

UiPath arguments example

In UiPath, a variable has scope within the sequence in which it is defined, and any sub-block that sequence contains. However, a variable defined in one sequence or workflow cannot be referenced directly in another. UiPath variable scope does not cross a workflow’s boundaries.

So how do you use a variable defined in one workflow in another? The answer is to configure a UiPath argument. The UiPath argument allows a variable’s value to be copied from one workflow to another.

UiPath argument directions

There are three types of argument directions in UiPath Studio:

  • in arguments
  • out arguments
  • in and out arguments

To pass a value from one sequence to another, the in argument is used.

If you create a variable in a workflow and want the value of that variable sent to another workflow, the out direction is used.

To receive the value of a variable, and then change that variable and update the workflow that passed it in, and in out direction needs to be used.

How to create UiPath Arguments

To create a UiPath argument, follow these steps:

  1. In the workflow that either gets passed in, or passes out data, create a variable in the Arguments panel
  2. Give the argument a name
  3. Set the direction of the argument
  4. Set the argument’s data type
  5. In the calling program, map the argument to a variable or a literal value.

Once the argument is mapped it will behave exactly the same way a variable would. You can include the argument in calculations. You can concatenate the argument with other variables and arguments, and you can specify the argument as a value in the properties tab of an activity.

UiPath arguments example

UiPath arguments are mapped to variables in the calling sequence.

UiPath argument naming conventions

To distinguish UiPath arguments from variables, a special naming convention is recommended. Depending on the direction, the argument must be prefixed with either in, out or io. The prefix is followed by a snake-case underscore, and then the argument is named using Pascal Case. Or to put it more simply, argument should start with either in_, out_ or io_.

Generally speaking, variables are not visible outside the activity in which they are defined. To overcome this limitation, and to make it possible to pass variables between worflows and flowcharts, UiPath arguments must be used.