Javascript Code Block
Last updated
Last updated
This block executes javascript code on the site page.
Below is a screenshot of the block settings.
There are two modes of operation of the block: Active tab and Background. The first mode works after opening the active tab using the New Tab or Active Tab blocks. The second mode works in the context of the browser in which the Goless workflow is running, an active browser tab is not required.
Block Settings:
Timeout. Delay in executing javascript code, default value 20000ms (20 seconds). If the delay is exceeded, the workflow continues to run the next block.
Execute Every New Tab. This will run the JS code when GoLess creates or switches to a new tab. If you enable this option, the JS code block will no longer need an active tab and built-in functions such as golessRefData, golessNextBlock.
Run before page loaded. Executing the JS code before loading the page. This setting is only available in Active tab mode.
JavaScript code. This is the field for entering the js code that is executed by the workflow.
Preload Script. Load a javascript file before running the JS code.
There are several integrated fuctions that you can call inside the code.
golessNextBlock(data, insert?)
Instructs the workflow to keep running the next block.
To insert data into the table, use the data
parameter. This parameter can take an object or an array of object data types. You can define the key of the object in the table.
The insert
parameter controls whether to insert the data in the data parameter into the table. Set to true
by default. It is also possible to pass an object that contains two optional properties:
insert
: insert data into the table or not.
nextBlockId
: a string specifying the following block's ID to move to.
golessSetVariable(name, value)
Defines the value of the workflow variables.
golessRefData(keyword, path)
Use it to access workflow data such as table, variables, etc.
golessFetch(type, resource)
Perform an HTTP request in the extension's background in order to prevent CORS.
type
: type of the request answer. Possible values text
& json
;
resource
: the resource that you wish to retrieve.
golessResetTimeout()
Use this function to reset the runtime.