# setVar

## Description

Creates a global variable with a value associated to it.

## Input / Parameter

| Name  | Description                           | Input Type  | Default | Options | Required |
| ----- | ------------------------------------- | ----------- | ------- | ------- | -------- |
| var   | The name of the variable to create.   | String/Text | -       | -       | Yes      |
| value | The value associated to the variable. | String/Text | -       | -       | Yes      |

## Output

| Description                                | Output Type |
| ------------------------------------------ | ----------- |
| Returns the value of the variable created. | String/Text |

## Callback

N/A

## Video

Coming Soon.

## Example

### Steps

1. Drag the `setVar` function into the flow window. ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-5c0e6d399a56a9f465e728eb0c9b06652fc06efa%2FsetVar-step-1.png?alt=media)
2. Create a variable called `version` with the value `1.0.0` ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-355902351231b29fcf9d5d83a439152be45eea5b%2FsetVar-step-2.png?alt=media)
3. This will create a global variable called "version" containing the value "1.0.0" that can be accessed by other components or on other pages of your app.

### Result

The value of the global variable `version` can be accessed by using the [`getVar`](https://github.com/OrangeKloud/emobiq-documentation/blob/master/document/client/006-actions-and-visual-logic/action-reference/cordova/App/setVar/getvar/README.md) function.

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-a70e4a68c2af62a28dd0d0a8bdf2bd5a61050552%2FsetVar-step-3.png?alt=media)

Using the above flow will display the value `1.0.0` in the browser console.

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-89a7c4b93a41f40e1df9ee1d9b9960538d885ca9%2FsetVar-step-4.png?alt=media)

## Links

* See also [`getVar`](https://github.com/OrangeKloud/emobiq-documentation/blob/master/document/client/006-actions-and-visual-logic/action-reference/cordova/App/setVar/getvar/README.md)
