Example Script Variables
An example of how to use a script variable is outlined below:
- Navigate to ScriptRunner > Script Variables.
- Click Create Script Variables from either the previously created list or the initial landing screen. The Create Script Variable screen appears:
- Enter a name in the Script Variable name field. For this example, we use
EXAMPLE_VAR. - Enter a password in the Script Variable value field. For this example, we use
I am an example. You can click the eye icon next to this field to make it visible or not visible, as required. - Click Save.Once saved, a confirmation message displays, and you are automatically redirected to the Script Variables page, as shown in the example below:
- Navigate to the Script Console.
- Click Script Context from the code editor, as shown below:The Script context modal appears with details of parameters/variables that are available for your scripts, including the script variable
EXAMPLE_VARcreated in the previous steps. For example: - Close the Script context modal and enter
println EXAMPLE_VARin the code editor. - Click Run. Once complete, you will see the Script Variable value previously created in Step 4 display in the Logs, as shown below.Tip: In this example, we referenced the saved script variable in the Script Console code editor. Saved script variables can also be referenced using the Script Context button in the editors for Script Listeners, Workflow Perform Actions, Scheduled Jobs, and Escalation Service.