diff --git a/Specialized Areas/Beautify JSON Data in String Fields/README.md b/Specialized Areas/Beautify JSON Data in String Fields/README.md new file mode 100644 index 0000000000..885552829e --- /dev/null +++ b/Specialized Areas/Beautify JSON Data in String Fields/README.md @@ -0,0 +1,8 @@ +**Details** +1. This script will format the JSON data in string fields on forms. +2. There is on OOB attribute "json_view" which can be added to field but it always reqires an extra click and has loading time issues. + +**How to use** +1. Run this script as Fix Script. +2. Replace the table name and encoded query as per your requirement. +3. Replace the field to be formatted as per the table selected. diff --git a/Specialized Areas/Beautify JSON Data in String Fields/script.js b/Specialized Areas/Beautify JSON Data in String Fields/script.js new file mode 100644 index 0000000000..2c8fa95971 --- /dev/null +++ b/Specialized Areas/Beautify JSON Data in String Fields/script.js @@ -0,0 +1,9 @@ +/* +This script will format the JSON data in string fields on forms. +There is on OOB attribute "json_view" which can be added to field but it always reqires an extra click and has loading time issues. +*/ +var chReq = new GlideRecord('change_request'); // Glide table. +chReqch.get('c83c5e5347c12200e0ef563dbb9a7190'); // sys_id of record, can be replaced with encoded query for multiple records. + +chReq.u_json_field = JSON.stringify(JSON.parse(chReq.u_json_field), null, "\t"); +chReq.update();