Custom Functions (New UI)

In DocuMotor it is possible to define custom functions. These custom functions apply the transformations defined. This guide will describe how a custom function is configured.

It is possible to use custom functions in other transformations e.g. in Templates. When calling a custom function it is required to use # in front of the function name. For example if a function is named fullName it should be refered in the transformations as #fullName().

The view is split into two panes, the function pane and the testing pane. The function pane, on the left, contains all functionality for the custom function itself. That is the parameters and the function transformation. The right pane, the testing pane, contains three text editors for testing if the custom function works.

The Function Pane


To be able to pass on parameters to the custom function it is required to define the parameters in the top of the function pane. To create a parameter the user clicks the plus button to the right of the Parameters label. Each parameter needs a name that should be used when writing the function’s transformation in the text editor below.

By Value vs By Expression

A parameter can either be passed as by value or by expression. When a parameter is passed by value, it is evaluated when the function is called and the result is passed to the function. When a parameter is passed by expression it is not immediately evaluated on function call and instead evaluated in the scope where it is read in the function body. To pass a parameter by value, the ByValue label in the parameter should be turned on, which it is if it is purple. To pass a parameter by expression the user can toggle the ByValue label by clicking it and it will turn grey meaning that ByValue is turned off. ByValue is always turned on by default.

Function Transformation

Below the parameters is a text editor where the JMES tranformation, that the custom function applies, is configured. This transformation should refer to the parameters defined above the text editor, if there is any. To refer to parameters, a # is put in from of the parameter name.

The Testing Pane

Sample Data

The Sample Data text editor should contain an example of some sample data to test how to use data variables when calling the custom function.

Sample Transformation

The Sample Transformation text editor is used to test how to call the custom function. It is both possible to use hardcoded parameters or parameters from the Sample Data text editor. Below is an example of how to test call the function with both hardcoded parameters and parameters from the Sample Data.

Sample Result

The Sample Result shows the output from the Function Transformation in relation to how the Sample Transformation calls the function with hardcoded data or the Sample Data. The result of the above examples would look like this: