Skip to content

Script

Executes user-defined code. User can write custom workflow logic in Java, JavaScript, Python, R or Ruby programming languages.

Categories: helpers, developer-tools

Type: script/v1


Actions

JavaScript

Name: javascript

Executes custom JavaScript code.

Properties

NameLabelTypeControl TypeDescriptionRequired
inputInputOBJECT
Properties {}
OBJECT_BUILDERInitialize parameter values used in the custom code.null
scriptJavaScript CodeSTRINGCODE_EDITORAdd your JavaScript custom logic here.true

JSON Example

{
"label" : "JavaScript",
"name" : "javascript",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/javascript"
}

Python

Name: python

Executes custom Python code.

Properties

NameLabelTypeControl TypeDescriptionRequired
inputInputOBJECT
Properties {}
OBJECT_BUILDERInitialize parameter values used in the custom code.null
scriptPython CodeSTRINGCODE_EDITORAdd your Python custom logic here.true

JSON Example

{
"label" : "Python",
"name" : "python",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/python"
}

Ruby

Name: ruby

Executes custom Ruby code.

Properties

NameLabelTypeControl TypeDescriptionRequired
inputInputOBJECT
Properties {}
OBJECT_BUILDERInitialize parameter values used in the custom code.null
scriptRuby CodeSTRINGCODE_EDITORAdd your Ruby custom logic here.true

JSON Example

{
"label" : "Ruby",
"name" : "ruby",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/ruby"
}

Additional instructions


Calling a component inside a script

To call a component inside a script, you need to use the context.component object which gives you references to components and their actions.

For example, to call logger component and its info action in javascript you can use the following code:

function perform(input, context) {
context.component.logger.info({'text': 'Hello World!!!'})
return null;
}

If you want to call an action of a component which requires a connection you can define its connection inside the Script editor:

You can also define multiple connections of the same component and then reference a particular connection when calling the action: