Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

AEM forms 6.5 view the request body when submitting with Form Data Model

Avatar

Level 1

Hi,

 

Does anyone know how to view the request body when submitting a form using the "Submit using Form Data Model" submit action?

 

It seems the form submits the form data, to {formUrl}/jcr:content/guideContainer.af.internalsubmit.jsp then it must get restructured in the back end before it gets sent to the destination end point.

 

It would be helpful for debugging if I could view the web request body (ie: the JSON data) either at the point of submission or a log somehow?

 

Any ideas?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@phantomsalt  You can put getdata call on submit and log the data in the console.

 

https://helpx.adobe.com/experience-manager/6-5/forms/javascript-api/GuideBridge.html

 

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();
         }
    }
});

View solution in original post

5 Replies

Avatar

Employee Advisor

@phantomsalt 

You should be able to review the request Form data using the browser devtool at the time of form submission to data model.

Also, you can capture debug level logs for the packages com.adobe.aemfd.dermis and com.adobe.aem.dermis to get additional logging to troubleshoot FDM related issues.

Hope this helps!

Avatar

Level 1

Thanks for the reply @Pulkit_Jain_ !

 

Unfortunately the data that is submitted at time of submission is not the same data structure that is submitted to the external endpoint.

 

For example the simple form I am using submits this:

{"guideState":{"guideDom":{"name":"guide1","templateId":"guideContainer__","guideNodeClass":"guideContainerNode","id":"","dorType":"none","schemaRef":"/content/dam/formsanddocuments-fdm/test/pets","schemaType":"formdatamodel","rootPanel":{"name":"guideRootPanel","templateId":"guideContainer-rootPanel__","guideNodeClass":"rootPanelNode","items":{"guidetextdraw_903352284":{"name":"textdraw_9033522841612237036617","templateId":"guideContainer-rootPanel-guidetextdraw_903352284__","_value":"<p><b><br />\nFetch dog</b></p>\n","guideNodeClass":"guideTextDraw"},"guidetextbox":{"name":"fetch_dog_id","templateId":"guideContainer-rootPanel-guidetextbox__","guideNodeClass":"guideTextBox"},"guidetextdraw_800693467":{"name":"fetch_dog_name","templateId":"guideContainer-rootPanel-guidetextdraw_800693467__","guideNodeClass":"guideTextBox"},"guidebutton_2099351445":{"name":"fetch_dog_button","templateId":"guideContainer-rootPanel-guidebutton_2099351445__","guideNodeClass":"guideButton"},"guidetextdraw":{"name":"textdraw1612236867583","templateId":"guideContainer-rootPanel-guidetextdraw__","_value":"<p><b>Create dog</b></p>\n","guideNodeClass":"guideTextDraw"},"id1612236405505":{"name":"id_1","templateId":"guideContainer-rootPanel-id1612236405505__","_value":"1234","guideNodeClass":"guideTextBox"},"name1612236413240":{"name":"name_2","templateId":"guideContainer-rootPanel-name1612236413240__","_value":"John","guideNodeClass":"guideTextBox"},"guidebutton":{"name":"","templateId":"guideContainer-rootPanel-guidebutton__"},"guidebutton_723256508":{"name":"create_dog_button","templateId":"guideContainer-rootPanel-guidebutton_723256508__","guideNodeClass":"guideButton"},"submit":{"name":"submit1612238835790","templateId":"guideContainer-rootPanel-submit__","guideNodeClass":"guideButton"}}}},"guideContext":{"customPropertyMap":{"runtimeLocale":"en","lastFocusItem":"guide[0].guide1[0].guideRootPanel[0].id_1[0]","fileAttachmentMap":"{}"},"disablePreview":false,"schemaRef":"/content/dam/formsanddocuments-fdm/test/pets","scriptingBehaviourVersion":"None","makeFileNameUnique":false,"schemaType":"formdatamodel","guidePath":"/content/forms/af/test/test_data_model/jcr:content/guideContainer","guideName":"guide1","afSubmissionInfo":{"computedMetaInfo":{},"stateOverrides":{},"signers":{}}},"additionalSubmitInfo":{}}}

And all of that gets converted to this and sent to the end point somehow:

{
   "id": 1234,
   "name": "John"
}

This 2nd one is the one I actually care about.

 

Do you have any links to documentation explaining how to capture the debug level logs for those packages?

Avatar

Employee

Regarding logging in AEM and configuring:

Logging | Adobe Experience Manager

You can add log files and store class or package specific messages also setting the log level to DEBUG

 

Avatar

Correct answer by
Employee Advisor

@phantomsalt  You can put getdata call on submit and log the data in the console.

 

https://helpx.adobe.com/experience-manager/6-5/forms/javascript-api/GuideBridge.html

 

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();
         }
    }
});

Avatar

Level 1

Brilliant! Thanks Mayank, this will suit my use case perfectly.

 

I can get even more specific to just get the data I am interested in:

guideBridge.getData({
    success : function (guideResultObject) {
	var data = JSON.parse(guideResultObject.data);
        console.log(data.afData.afBoundData.data);
    },
    error : function (guideResultObject) {
         console.error("API Failed");
         var msg = guideResultObject.getNextMessage();
         while (msg !== null) {
             console.error(msg.message);
             msg = guideResultObject.getNextMessage();
         }
    }
});