# Global Variable

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.

## Contents

* [Global Variable](#global-variable)
  * [Get started with global variables](#get-started-with-global-variables)
  * [Edit or Delete Variable](#edit-or-delete-variable)
  * [How to use Global Variable inside Manual Asset](#how-to-use-global-variable-inside-manual-asset)
  * [Related topics](#related-topics)

***

### Get started with global variables

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.

![FolderPage](/files/rPpxC01gEx8zK8QQF59l)

![GlobalVariableLanding](/files/mQu0AjTw5UWn9GpoEivb)

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.

![NewVariable](/files/5N3ra2dWHFpVtXIQB8Ss)

Let's understand all input type turn by turn.

1. **Variable Name**: Give a unique name to identify your variable
2. **Type**: We provide several types to create a variable

   | Variable Type | Description                                                                                                                                                         |
   | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `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.                                                                                                                                    |
3. **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.

![VariableExample](/files/jKro2cyyoGrFmvF4JIix)

***

### Edit or Delete 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.

***

### How to use Global Variable inside Manual Asset

Go inside the manual asset in which you want to use the global variable.

You can make use of global variables in fields like,

```
* Path Parameter
* Query Parameter
* Request/Response Body
* Headers
```

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

![VariableUsage](/files/gfuIxhJPxf5grTLjarFy)

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"

![VariableResult](/files/vsMWpUoKnMkWqQRmcFvc)

This is the magic of a global variable. You can make use of the same variable n times.

***

### Related topics

* [Paramterization](/service-virtualization/advanced-features/parameterization.md)
* [Strict Mode](/service-virtualization/advanced-features/strict-mode.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.qyrus.com/service-virtualization/advanced-features/global-variable.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
