Expand my Community achievements bar.

Transition from button rules that use guidelib.dataIntegrationUtils.executeOperation() to client libs

Avatar

Level 1

I am currently transitioning button rules from an adaptive form to client libs. In my rules I have the following. 

var operationInfo = {
            "formDataModelId": "/content/test/formsanddocuments-fdm/myproject/samplepostgres",
            "operationTitle": "Fetch From Attachment Form",
            "operationName": "fetch"
        };
        var inputs = {
            "id": id.value
        };
        var outputs = {
            "id": id,
            "name": name,
            "description": description
        };
        guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, null, null,);
 
This works as expected. It fetches the data using the id and prepopulates the id, name, and description form fields with the retrieved data. For my client lib I have the following and get the error I have attached:
$(".fetchbutton").click(function () {
        var idNode = guideBridge.resolveNode(
            "guide[0].guide1[0].guideRootPanel[0].attachmentform[0].id[0]"

        );
        var nameNode = guideBridge.resolveNode(
            "guide[0].guide1[0].guideRootPanel[0].attachmentform[0].name[0]"

        );
        var descriptionNode = guideBridge.resolveNode(
            "guide[0].guide1[0].guideRootPanel[0].attachmentform[0].description[0]"

        );
        var idValue = idNode.value;
        var operationInfo = {
            "formDataModelId": "/content/test/formsanddocuments-fdm/myproject/samplepostgres",
            "operationTitle": "Fetch From Attachment Form",
            "operationName": "fetch"
        };
        var inputs = {
            "id": idValue
        };
        var outputs = {
            "id": idNode,
            "name": nameNode,
            "description": descriptionNode
        };
        
        guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, null, null);
 

jesus_ibarra_0-1703177751198.png

jesus_ibarra_1-1703178142510.png

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Employee

I am not able to comprehend the usecase where you want to make it a page level client library. In any case the issue is with 

 var outputs = {
            "id"idNode,
            "name"nameNode,
            "description"descriptionNode
        };
As the thirdparty code will not understand this.

Recommendation is to make it a client library to be associated with form. So on click of a button, you can write a "visual rule" to invoke a custom function (in follwoing example myForm.execute_service). And the clientlibrary will have the js with the custom function looking like:

 

var myForm = window.myForm = window.myForm || {};

/**
 * @function myForm.execute_service
 * @Param {scope} scope in which code inside function will be executed.
 */
myForm.b2_evacuateIndependently_valueCommit0 = function (scope) {
    with(scope) {
       var operationInfo = {
            "formDataModelId": "/content/test/formsanddocuments-fdm/myproject/samplepostgres",
            "operationTitle": "Fetch From Attachment Form",
            "operationName": "fetch"
        };
        var inputs = {
            "id": id.value
        };
        var outputs = {
            "id": id,
            "name": name,
            "description": description
        };
        guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, null, null,);
    }

 

Doc link: Check heading "Custom functions in rule editor" in https://experienceleague.adobe.com/docs/experience-manager-65/content/forms/adaptive-forms-advanced-... 

Avatar

Level 10

@Sakshi5  some reason the guidelib is undefined for me . In custom client lib . Any dependencies? The myform is empty . I am on AEMaaCS core form component and not using foundation template but new r version of template