Toggle menu

Basic Browser Calls

This example calls a public end point when a field is updated. You could use a similar function in a script button.

Although we've included it as an example, you'll hardly ever use this functionality. It relies on the end point being published to the public ajaxlibrary, which means it is completely open to the internet. Given the lack of security, the end point should be very limited in what it does.

The function has been placed in the handler of a text field and uses .utilInvokeAPIServer. The worker is the publicly available ajaxlibrary worker, the method a simple end point "formstraining.crypto" which generates a hash of the string passed to it.

When the value of the text field changes, the text is passed to the end point and the result updates a guidance text field, "GUIDANCE".

function(helper, fieldName, value, valid, eventName) {
    if (eventName == 'CHANGE' && valid) {
        helper.utilCreateAPIServer('APIServer', '/apiserver/ajaxlibrary', {});
        helper.utilInvokeAPIServer('APIServer', 'formstraining.crypto', {
                'text': value
            },
            //The ok function. Update the guidance text with the successful result
            function(data) {
                helper.setFieldValue('GUIDANCE', 'The hash of the text you just entered: ' + JSON.stringify(data));
            },
            //The error function. Update the guidance text with any error message
            function(errorDetails, errorMessage) {
                helper.setFieldValue('GUIDANCE', 'apiServercall ERROR: ' + errorMessage + " " + JSON.stringify(errorDetails));
            }
        );
    }
}

Share this page

Facebook icon Twitter icon email icon

Print

print icon