Save web form's data in JSON

I am developing a web application on the version 11, I want to Save my form data in JSON format in a single column of an entity and retrieve the saved JSON to prepopulate field of the form.

Ex: Say, I have a Product table and I want to save the single product details in JSON format in that Product table.

Hi Sughash,

That is possible, to save it:

  1. On your entity create a new attribute type text (if you are sure that the max length of 2000 characters will not be exceded for your json, else make it type binary.
  2. Create a structure for your form data
  3. Use the JSONSerialize to convert the structure of your form data json
  4. Assign the output of the JSONSerialize to the entity attribute.

To show it again after reading:

  1. Add structure to your screen
  2. Assign structure to your form or form inputs
  3. After retrieving the data use the JSONDeserialize to transfrom the entity attribute with the json string to the structure.

A final not on large text (> 2000 characters), you could use the data type binary, and than the functions from the binary extension to translate from string to binary, and binary back to string. The benefit of this there is virtually no size limit to your json. the downside is you have to do additional coding.

Regards,

Daniel

Solution

Daniël Kuhlmann wrote:

Hi Sughash,

That is possible, to save it:

  1. On your entity create a new attribute type text (if you are sure that the max length of 2000 characters will not be exceded for your json, else make it type binary.
  2. Create a structure for your form data
  3. Use the JSONSerialize to convert the structure of your form data json
  4. Assign the output of the JSONSerialize to the entity attribute.

To show it again after reading:

  1. Add structure to your screen
  2. Assign structure to your form or form inputs
  3. After retrieving the data use the JSONDeserialize to transfrom the entity attribute with the json string to the structure.

A final not on large text (> 2000 characters), you could use the data type binary, and than the functions from the binary extension to translate from string to binary, and binary back to string. The benefit of this there is virtually no size limit to your json. the downside is you have to do additional coding.

Regards,

Daniel

Thanks for the response. 

These pointers worked for me.


Solution