Run JavaScript

<< Click to Display Table of Contents >>

Navigation:  Workflow Designer > Activities >

Run JavaScript

Previous pageReturn to chapter overviewNext page

Function

It can execute any JavaScript. The interpreter used for this is Jint. All limitations associated with Jint therefore also apply to Gooflow. For example, the window or DOM objects cannot be used.

 

Input

Script

The script to be executed.

 

Possible Outcomes

The possible outcomes that can be returned by the activity and that the workflow can use after executing the JavaScript code to control its further execution. These outcomes are defined as part of the activity’s configuration and can be dynamically set by the JavaScript code itself.

 

Default outcome: If the script does not specify a particular outcome, the default outcome is “Done”.

 

Example:

Suppose you have a JavaScript activity that processes a form submission. You can define possible outcomes such as “Success” and “ValidationError”. Depending on the logic of the script, it can set the outcome to “Success” if the form is valid, or to “ValidationError” if there are issues, and direct the workflow accordingly.

 

Output

Result

The variable in which the return value is stored. Different data types can be used, so if an object is returned, the data type Object should be defined for the variable, dito for strings etc.

 

Example:

const strauftrag = getVariable('pxAuftrag');

const jsonObject = JSON.parse(strauftrag);

const strBezeichnung = jsonObject.dfsBezeichnung;

const strAuftragNr  = jsonObject.dfsAuftragNrPRO;

const strAdressNr = jsonObject.dfnKunde;

setVariable('AdressNr', strAdressNr);

const strWrikeBaseUrl = getVariable('WrikeBaseUrl') + strAuftragNr + " " + strBezeichnung

return strWrikeBaseUrl;