Toggle menu

helper.createCustomFn(name, func, scope)

Custom functions are one way to create reusable functions in your form. They are registered in a server-side script, and are set with a scope that allows them to be called only in other server-side scripts, or be available both server and client-side.

Arguments

ArgumentTypeDescription
nameString, requiredName of the function, must be unique
funcFunctionThe function to execute
scopeString, requiredWhere the function can be invoked. One of:

helper.VARIABLE_SERVERONLY
helper.VARIABLE_SERVERCLIENT

Example

This function has been created in a server-side page initialisation handler:

Custom Function
 

function(helper, pageName, pageInstance, mode) {
    var options;
    helper.createCustomFn(
        'exampleFunction',
        () => {
            if (helper.getFieldValue('TEXTINPUT') != '') {
                options = helper.getVariable('DROPDOWN_OPTIONDATA');
                options.push([helper.getFieldValue('TEXTINPUT'), helper.getFieldValue('TEXTINPUT')]);
                helper.setVariable('DROPDOWN_OPTIONDATA', options);
            }
            return options;
        },
        helper.VARIABLE_SERVERCLIENT
    );
}

It checks for the value of a text field, and if found, adds the value to the options in a drop-down list.

The function can be invoked using .invokeCustomFn.

Share this page

Facebook icon Twitter icon email icon

Print

print icon