JSON field attribute
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Hi there,
A situation that sounds familiar when working with fields with JSON code: The JSON code hard to read, the code looks unformatted, the structure or errors are hard to spot. So let's open a JSON viewer on the web, copy/paste the code, parse it…
While actually, there's a dictionary attribute in ServiceNow which might help you a lot. A hidden gem, already available in ServiceNow for ages: "JSON View". Basically: it will present an icon next to the field label, when you click the icon: the JSON is nicely formatted in a pop-up!
Out-of-the-box
For example, let's have a look at the "Option schema" field on the "Widget" form. This is a JSON field type. As you can see, unformatted.
Adding the attribute
Within the Dictionary Entry of the field, select the "Attributes" section and click the "New" UI Action.
On the "Dictionary Attribute" new record, simply add:
Result
After submitting the new Dictionary Attribute, return to the Widget form again. The result will be visible instantly. A small icon next to the field label will be visible.
And now, simply click the icon. A simple pop-up window appears with the JSON code nicely formatted!
---
And that's it actually. Hope you like this hidden gem. If any questions or remarks, let me know!
Kind regards,
Mark Roethof
ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP
1x ServiceNow Community MVP
---
https://www.servicenow.com/community/developer-articles/json-field-attribute/ta-p/2321496
