Execute script
First of all, a script can be executed right from the script editor, as described in run script section.
Script is Datagrok function, and can be invoked in different ways:
- From the Datagrok console
- From the data job
- From the transformations editor
- From the function browser
Registered scripts can be called via JavaScript API in the following manner:
const result = grok.functions.call(
"<PACKAGE_NAME>:<SCRIPT_NAME>",
{
<INPUT_NAME>: <INPUT_VALUE>,
<INPUT_NAME_2>: <INPUT_VALUE_2>
}
);
caution
The single output will be assigned to result
directly. Multiple outputs will be united into a single object.
You can retrieve any output value by accessing result
object fields (e.g. result['<MY_OUTPUT>']
).
To see it in action, open this code snippet from our samples gallery.