Sample script to invoke a service

The following sample script uses the guidelib.dataIntegrationUtils.executeOperation API to invoke the getAccountById service operation configured in the employeeAccount form data model.

The getAccountById operation takes the value in the employeeID form field as input for the empId argument and returns employee name, account number, and account balance for the corresponding employee. The output values are populated in the specified form fields. For example, the value in name argument is populated in the fullName form element and value for accountNumber argument in account form element.

var operationInfo = {
"formDataModelId": "/content/dam/formsanddocuments-fdm/employeeAccount",
"operationName": "getAccountDetails"
};
var inputs = {
"empid" : employeeID
};
var outputs = {
"name" : fullName,
"accountNumber" : account,
"balance" : balance
};
guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs);

Using the API with callback function

You can also invoke the form data model service using the guidelib.dataIntegrationUtils.executeOperation API with a callback function. The API syntax is as follows:

guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, callbackFunction)

The call back function can have success and failure callback functions.

Sample script with success and failure callback functions

The following sample script uses the guidelib.dataIntegrationUtils.executeOperation API to invoke the GETOrder service operation configured in the employeeOrder form data model.

The GETOrder operation takes the value in the Order ID form field as input for the orderId argument and returns order quantity value in the success callback function. If the success callback function does not return the order quantity, the failure callback function displays the Error occured message.

NOTE
If you use the success callback function, the output values do not populate in the specified form fields.
var operationInfo = {
    "formDataModelId": "/content/dam/formsanddocuments-fdm/employeeOrder",
    "operationTitle": "GETOrder",
    "operationName": "GETOrder"
};
var inputs = {
    "orderId" : Order ID
};
var outputs = {};
var success = function (wsdlOutput, textStatus, jqXHR) {
order_quantity.value = JSON.parse(wsdlOutput).quantity;
 };
var failure = function(){
alert('Error occured');
};
guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, success, failure);

Experience Manager


Espressos & Experience Manager: AEM Forms

Espressos & Experience Manager

Thursday, Mar 6, 7:00 PM UTC

Join Adobe's AEM product team as they highlight AEM Forms' latest innovations, including: the new Gen AI Assistant, Unified Composition with AEM Sites, and new ways to deploy forms through conversations.

Register

Rapid Feature Releases with AEM Cloud: Telegraph Media Group’s RDE Strategy

Online | Session | Intermediate

Hear how Telegraph Media Group, the award-winning publisher of The Daily Telegraph, The Sunday Telegraph, The Telegraph Magazine,...

Wed, Mar 19, 3:30 PM PDT (10:30 PM UTC)

Register

Driving Marketing Agility and Scale: Transforming your Content Supply Chain with AI

Online | Strategy Keynote | General Audience

Marketers everywhere are feeling the pressure to deliver impactful campaigns faster and at greater scale. This Strategy Keynote explores...

Tue, Mar 18, 2:30 PM PDT (9:30 PM UTC)

Register

Connect with Experience League at Summit!

Get front-row access to top sessions, hands-on activities, and networking—wherever you are!

Learn more