Expand my Community achievements bar.

How to extract JSON schema from HTML5 Form

Avatar

Level 2

Hi all, 

I have a use case and wanted to get your thoughts and suggestions to move forward with implementation.

We design forms (XDP) and then bind them to a JSON schema. We share a bcs file with our partners that explains them what each field on the form accepts.

As you know, based on these defined bindings, we render the form with request payload (JSON) and generate a fillable prefilled PDF document. Our render service is a custom service built on top of Forms render service, only difference being request is a JSON payload unlike XML.

We are now trying to render these XDPs as HTML5 forms and need a way to generate this JSON from within the HTML form, so we can feed that JSON data to our downstream systems. I do not see a straight forward way to implement this as JSON would contain the binding names versus XML which contains object names. We looked at Form Bridge API but it can only export XML. Ony possibility is building the JSON structure based on all bindings available in the form. Does this make sense ? any other better ways to get this done ?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Administrator

@Pranay_M @ankumitt @wizard04wsu @Vijay_Kumar_Jalagari @Lokesh_Vajrala @Taz_2424 Whenever you have a moment, please check out this question and share your knowledge!



Kautuk Sahni

Avatar

Employee

Hi @kolluax,

Rendering XDP forms as HTML5 and generating JSON from them involves a few complexities due to the nature of the data binding and form rendering process. The existing challenge you face seems to center around the direct generation of JSON from HTML forms, a task that traditionally aligns more with XML due to the legacy of form technologies.

  • The JSON payload you use for rendering forms contains binding names specific to each field. When transforming this to HTML5, the challenge is maintaining these binding names so that the generated JSON accurately reflects the data structure needed downstream. As you noted, the Form Bridge API primarily supports XML export. This is because XML is a more traditional format for structured data in forms, largely due to the older form technologies.
  • You mentioned the possibility of building the JSON structure based on all bindings available in the form. This is a viable path and involves extracting the binding information from the XDP during form design and using it to map HTML5 form data back to JSON.
  • Use JavaScript to extract values from the HTML5 form and construct a JSON object. You could design a script that runs when the form is submitted, collects data from each field, and maps it to the corresponding binding names

Thanks

Pranay