The Run Script element allows you to execute JavaScript code within your project. Below are its functionalities, limitations, and examples to guide proper usage.Documentation Index
Fetch the complete documentation index at: https://docs.release0.com/llms.txt
Use this file to discover all available pages before exploring further.
Key Features
- The Script element enables you to execute JavaScript code, but it does not allow you to create custom visual elements.
- Variables in the script are evaluated, not parsed, so they must be treated as real JavaScript variables.
Note: Useconsole.log({{My variable}})instead ofconsole.log("{{My variable}}").
setVariable Function
Purpose
If you want to set a variable value with Javascript, the Set Variable is more appropriate for most cases. HoweversetVariable function allows you to set values within a Script element.
Example
Important:
- The
setVariablefunction is only available in scripts executed on the server.- It will not work if the Execute on client? option is checked.
Server-Side Script Limitations
When scripts are executed on the server, they run in a secure, isolated environment. As a result, some JavaScript functionalities are restricted:Restricted Functions
- Global functions like
console.log,setTimeout, andsetIntervalare not available. - Importing external libraries using
importorrequireis not supported. - Browser APIs like
window,document, andlocalStorageare not accessible.
Fetch Behavior
The behavior of thefetch function differs from the native implementation:
- The
responsewill always be a string, even if the server returns a JSON object. - You need to manually parse the response using
JSON.parse().
Examples:
Note: Avoid usingawait response.text()orawait response.json().