How to save form fragment data individually

ramandeep

30-05-2020

Hi Guys,

 

I am learning to save adaptive form data using mysql database and I am able to save complete form data as an xml in the database in one column. I am using sling servlet to get and add data to the database and guidewire api as an ajax request to get/post data on the form. I am using form fragments and my form xml data is very large. There is only one submit button on the form which is submitting the whole form data as an xml. Is there any way I can divide the form xml data into parts corresponding to form fragments and save the corresponding form data into multiple mysql tables?

1. Save one complete xml/json form data into multiple tables.

2. Get form data as a single entity in xml/json data from the multiple mysql tables.

 

Thank you in advance.

Accepted Solutions (1)

Accepted Solutions (1)

BrianKasingli

MVP

25-07-2020

Hello @ramandeep

Sure you can use the GuideBridge API to save the XML schema based on the user's behaviour, but It would be very difficult to save/manage sets of XML in chunks within the MySQL DB. To retrieve and stitch files the XML schema together would be troublesome (as the form's XML structure can be always changing).

Since you said you have a very large fragment, you must be worried about the data being corrupted being saved. What you can try is:

  1. After a form have been submitted, save the XML data into a reserved node inside of the AEM publish, example, /var/my-jobs/submitted-forms.
  2. Create a JCR listener to listen for any node addition to the folder, to trigger a custom action.
  3. The custom action will try to POST the XML data to the MySQL database with a fail-safe mechanism, by utilising a custom sling servlet.

I hope this helps,

Brian.