Global Variable
Last updated
Last updated
Global variables are basically variables that can be created once and reused any number of times across the same project. They can be used in Manual Assets.
Enter a project and navigate to the asset folder section. Inside, you'll come across a button labeled "Global Variables" in the top right corner. When you click on this button, you will be taken to the Global Variable Page.
As shown in the above image, Click on the "New Variable" button to create a new global variable.
As soon as you click on the "New Variable" button, you'll find 3 fields to give value to a global variable.
Let's understand all input type turn by turn.
Variable Name: Give a unique name to identify your variable
Type: We provide several types to create a variable
Custom
As the name says, the value can be of a custom type and can be used as a global variable.
Integer
Generates a random integer value between the minimum and maximum values entered.
Decimal
Generates a random decimal value between the minimum and maximum values entered and the decimal count defines the number of decimal points after the integer value.
UUID/GUID
Generates a random UUID/GUID value for the variable entered.
Email
Enter a valid e-mail address that can be used.
Date
Enter a date in the valid format that can be used.
Firstname
Firstname will be auto-generated.
Lastname
Lastname will be auto-generated.
Variable Value: Provide valid input as mentioned above.
For Firstname and Lastname Variable value is not required as it'll be auto-generated.
Once you give all the values, you can click on the "Save" button and a variable will be created. Also, if you wish to create multiple variables, click on the plus button as shown below and add a new variable.
If you wish to edit any variable name, type, or value, you can come back any time make the necessary changes, and click on the "Save" button as shown above to publish your changes.
If you want to remove any unused variables, click on the "Bin" button next to the Variable value field and it'll ask for confirmation and your variable will be deleted.
Once you delete the variable, the process can't be undone.
Go inside the manual asset in which you want to use the global variable.
You can make use of global variables in fields like,
The pattern to use the global variable is shown below.
#VariableName#
Let's understand this using an example,
Suppose you want to use a global variable in 1 field inside your response body. You can make use of it as shown below image
Click on the "Update" button and "Hit" the request to see the result.
It'll replace the variable name with the actual value in real-time. In the above example, we gave a value of "23". so it'll be replaced with "23"
This is the magic of a global variable. You can make use of the same variable n times.