Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Guide Result Object result in XML

Avatar

Level 2

Hi All,

 

I am new to AEM Forms. I am using GuidBridge API to get form data.

guideBridge.getData({
    success : function (guideResultObject) {
         console.log("data received" + guideResultObject.data);
    }
    error : function (guideResultObject) {
         console.error("API Failed");
         var msg = guideResultObject.getNextMessage();
         while (msg != null) {
             console.error(msg.message);
             msg = guideResultObject.getNextMessage();
         }
    }
});

However, I need the result in JSON format. The result is being logged in XML format as shown below - 

<?xml version="1.0" encoding="UTF-8"?>
<afData>
<afUnboundData>
<data>
<tag1>234561234567890987654</tag1>
<tag2>xcvghjklkjh</tag2>

</data>
</afUnboundData>
<afBoundData>

<data
xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\"/>
</afBoundData>
<afSubmissionInfo>
<lastFocusItem>guide[0].guide1[0].guideRootPanel[0].RandomForm[0].companyDetails[0]</lastFocusItem>
<computedMetaInfo/>
<stateOverrides/>
<signers/>
<afPath>/content/dam/formsanddocuments//randomPath</afPath>
<afSubmissionTime>20210625074410</afSubmissionTime>
</afSubmissionInfo>
</afData>

 

How can I get the guideResultObj.data to be in JSON format ?

The form does not have any JSON schema associated with it as it was created with a blank template.

1 Accepted Solution

Avatar

Correct answer by
Level 10

@gargrohan You are using correct api but the approach need to be changed. You will get json only if the form is bound to a json schema.

Same api will result in json instead of XML.

Navigate to form properties and map json schema to the form. Now go to form objects and bind the field as required and call the api and, that's it.

https://experienceleague.adobe.com/docs/experience-manager-65/forms/adaptive-forms-advanced-authorin...

View solution in original post

2 Replies

Avatar

Employee Advisor

@gargrohan 

You should be able to convert the XML into JSON format as below:

guideBridge.getData(     
{
success : function (guideResultObject)
{
FormData= $.parseJSON(guideResultObject.data);
});

 

Hope this helps!

Avatar

Correct answer by
Level 10

@gargrohan You are using correct api but the approach need to be changed. You will get json only if the form is bound to a json schema.

Same api will result in json instead of XML.

Navigate to form properties and map json schema to the form. Now go to form objects and bind the field as required and call the api and, that's it.

https://experienceleague.adobe.com/docs/experience-manager-65/forms/adaptive-forms-advanced-authorin...