Toggle menu

helper.utilServerAPIServerCall(worker, methodName, params, advanced)

Makes server-side calls to an API Server worker and parses the response.

Unlike .utilInvokeAPIServer, utilServerAPIServerCall "understands" the responses it gets back from three common workers - icmapi, formutils and workflow - and also processes the responses from others.

If the response contains a "result" property, that is returned. If it contains multiple, nested, result properties, the final one is returned.

If the request was made to the iCM API worker, the function will look for and return the "multipleItemData" or "itemData" properties.

Errors are turned into exceptions.

This functionality can be turned off by setting "rawMode" as true.

Additional options (like user credentials) can be supplied in the advanced property. By default, if you don't provide your own "options" object, the "internal" flag is set as true.

Executed

Server-side only.

Arguments

ArgumentTypeDescription
workerString, requiredThe name of the worker to call
methodNameString, requiredThe method of the worker (or End point name if calling an end Point capable worker)
paramsObject, requiredThe parameters to pass to the worker method
advancedObject, optionaloptionsObjectAny advanced options, matching those of .utilCreateAPIServer, although note that the internal flag is set true by default (so you can easily calls internal workers, like the iCM API)
urlStringA non standard URL for the API Server (will be combined with the worker name)
rawModeBooleanTrue to return the full response without any parsing

Example

This function also exists as a block in the Form Designer's visual editor. See Server-side Calls for an example.

The two guidance text fields below the code sample show the default behaviour and "raw mode".

A query is made to the iCM API using each field's default function. The results have been turned into strings so you can see them.

function (helper, defaultValue, currentValue) {
    var request = helper.utilServerAPIServerCall("icmapi", "CSArticle_get", {
        "get": "ArticleHeading",
        "set":{
            "ArticleID": 1
        },
    },{
        "options": {
            "apiKey": "83A9ABB3-xxxx-xxxx-xxxx-9E2E7673137F"
        },
        "rawMode": false
    });
    return JSON.stringify(request);
}

Guidance Text Fields:

Share this page

Facebook icon Twitter icon email icon

Print

print icon