Generate form dynamically based on json at runtime

RishabhB
Tera Contributor

Hello,

 

Can someone please guide me on how to achieve a functionality in service portal where a form needs to be dynamically generated based on a JSON file uploaded?

 

Description- There should be a field for uploading a JSON in a catalog item. Once a file is uploaded, editable fields should be generated immediately based on the fields mentioned in the JSON file. Once it is submitted, a new request along with RITM should get created.

Note- The JSON file can be having any number of fields.

 

Thanks in advance!

1 REPLY 1

Matthew_13
Tera Guru

Hi RishabhB

 

ServiceNow does not support creating catalog item variables dynamically at runtime based on an uploaded JSON file. Variables are static by design.

Recommended (supported) approach

Use a custom Service Portal widget inside the catalog item:

  • Add a file upload in the widget

  • Parse the uploaded JSON (client/server)

  • Dynamically render fields using Angular (ng-repeat)

  • Capture user input back into a single JSON object

  • Submit the catalog item normally → RITM is created

  • Store the JSON on the RITM or a custom table

What won’t work

  • Dynamically creating catalog variables

  • Variable sets for unknown field counts

Bottom line:
ServiceNow’s supported solution is custom widget + JSON storage, not dynamic catalog variables.

 

@RishabhB  - Please give a thumbs up and Accepted Solution if you find Helpful!