AEM forms 6.5 view the request body when submitting with Form Data Model | Community
Skip to main content
New Participant
Aug 25, 2021 6:33 AM UTC
Solved

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

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Mayank_Gandhi
Mayank_GandhiAccepted solution
Employee
Aug 26, 2021 6:51 AM UTC

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

5 replies

Mayank_Gandhi
Mayank_GandhiAccepted solution
Employee
Aug 26, 2021 6:51 AM UTC

@thomaspl1  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();
         }
    }
});
Translate
ThomasPl1Author
New Participant
Aug 26, 2021 6:55 AM UTC

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



Translate
ThomasPl1Author
New Participant
Aug 25, 2021 7:10 AM UTC

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?

Translate
Kosta_Prokopiu1
Employee
Aug 25, 2021 7:28 AM UTC

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

 

Translate
Pulkit_Jain_
Employee
Aug 25, 2021 7:02 AM UTC

@thomaspl1 

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!

Translate