Expand my Community achievements bar.

SOLVED

Rule editor stuck on "Getting rules" when using client library

Avatar

Level 4

I am using an existing client library that has worked before. Now when I edit a new form, apply the client library, and try to open the rule editor, it gets stuck on "Getting rules".

 

I receive this error in the browser console:

guideCommonAuthoring.js:5404 Error in retrieving Expression or Form Objects JSON

And I receive this error from the error.log:

08.04.2021 15:02:02.917 *ERROR* [0:0:0:0:0:0:0:1 [1617919322913] GET /libs/fd/af/components/info.json HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught Throwable
org.mozilla.javascript.EvaluatorException: missing ; before statement (#33)

 

This is happening in my local and stage environments on AEM Version 6.5.3.

Has this issue happened to anyone else?

1 Accepted Solution

Avatar

Correct answer by
Employee

somewhere in the client lib the javascript code is giving you the error. The best way is to comment few lines of code at a time and load the rule editor till you narrow down the culprit line in the javascript

View solution in original post

8 Replies

Avatar

Employee

looks like this has to do with the client library associated with StoreAndFetch use case. The javascript code in the client library could be missing a semi colon. For the StoreAndFetch use case, you do not need to use the rule editor.

Avatar

Level 4

I am using the client library from this tutorial: https://experienceleague.adobe.com/docs/experience-manager-learn/forms/adaptive-forms/document-of-re...

 

Here is the modified js within the client library:

 

/**
* Get pdf
*  {OPTIONS} drop down options 
 */
function getPdf()
{
    console.log("in view pdf");
    window.guideBridge.getDataXML(
        {
        	success: function(result) {
             var formData = new FormData();
             formData.append("dataXml",result.data);
			console.log("got data"+result.data);
           	var settings ={
            				"async": true,
							"url": "/bin/name",
							"method": "POST",
                			data:{'data':result.data},
   						}
            $.ajax(settings).done(function(response, status, xhr)
            {
                console.log("got response from POST");

                // check for a filename
                var filename = "";
                var disposition = xhr.getResponseHeader('Content-Disposition');
                if (disposition && disposition.indexOf('attachment') !== -1) {
                    var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
                    var matches = filenameRegex.exec(disposition);
                    if (matches != null && matches[1]) filename = matches[1].replace(/['"]/g, '');
                }

				let binaryString = window.atob(response);
                let binaryLen = binaryString.length;
                let bytes = new Uint8Array(binaryLen);

                for (let i = 0; i < binaryLen; i++) {
                    let ascii = binaryString.charCodeAt(i);
                    bytes[i] = ascii;
                }

                let blob = new Blob([bytes], {type: "application/pdf"});
                let link = URL.createObjectURL(blob);

                var a         = document.createElement('a');
                a.href        = link; 
                a.target      = '_blank';
                a.download    = filename;
                document.body.appendChild(a);
                a.click();
            })

    	},
    	error:function(guideResultObject) {console.log("got error"); },
        guideState : null,
        boundData  : true});

}

 

Avatar

Level 4

The js is tested and working, however the rule editor no longer works when the client library is applied in the form container.

After removing the client library from the forms container, the rule editor starts to work again.

Avatar

Correct answer by
Employee

somewhere in the client lib the javascript code is giving you the error. The best way is to comment few lines of code at a time and load the rule editor till you narrow down the culprit line in the javascript

Avatar

Level 4
Changing the "let" statements to "var" made it work. Thank you for your help!

Avatar

Employee Advisor

@techddx avoid using let and const, these are not fully supported in forms.