Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Scripted Variables in JavaScript allow you to execute and assign values to variables that can be used in your web action config. This can be used in the post body, URL, and anywhere in your config using Mustache syntax ({{ variable-name }}).

Creata a Javascript variable

  1. Go to the Variables tab

  2. Toggle to Javascript variables

  3. Click the "Add" button

  4. Rename the variable in the "MyVar" field

  5. Write your script in the "Script" field

Script usage

The script must return a value, this value is assigned to the variable name and used in the configuration by entering mustache syntax.

The script has the following context already provided as variables to use;

response

the response of the parent action in raw text

jsonResponse()

a function that turns the response into json object

context

raw context of the action, such as name, url, method, headers

jsonContext()

a function that turns the context into json object.
example getContext().url gives the url

path(anyObject, jsonpath)

a function that returns the value in the object specified by the path.
Used when there is a need to pick a part of a json object.

getIssue()

return the issue as json if exists else null

  • No labels