JSON field attribute - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

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.

 

find_real_file.png

Adding the attribute

Within the Dictionary Entry of the field, select the "Attributes" section and click the "New" UI Action.

 

find_real_file.png

 

On the "Dictionary Attribute" new record, simply add:


find_real_file.png

 

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.

 

find_real_file.png

 

And now, simply click the icon. A simple pop-up window appears with the JSON code nicely formatted!

 

find_real_file.png

---

And that's it actually. Hope you like this hidden gem. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP

1x ServiceNow Community MVP

---

LinkedIn

Comments
Shakeel Shaik
Mega Sage
Mega Sage

Great and very useful.

Thanks for Sharing 🙂

Michael O J
Tera Expert

This is very usefull.

 

Does anyone know if it possible to improve it with color coding. Just like the "view XML" popup.

 

BR

Michael

Shashank_singh9
Tera Expert

Can this functionality be enable for users with itil role, because once they click the JSON button, it shows like this, the user already has access to record.

Shashank_singh9_0-1729677530501.png

 

Version history
Last update:
‎08-03-2024 07:36 AM
Updated by:
Contributors