Key Features
- The Script block enables you to execute JavaScript code, but it does not allow you to create custom visual blocks.
- 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 block.
Example
Important:
- The
setVariable
function 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
, andsetInterval
are not available. - Importing external libraries using
import
orrequire
is not supported. - Browser APIs like
window
,document
, andlocalStorage
are not accessible.
Fetch Behavior
The behavior of thefetch
function differs from the native implementation:
- The
response
will 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()
.