diff --git a/Specialized Areas/Fix scripts/Create Table JSON/README.md b/Specialized Areas/Fix scripts/Create Table JSON/README.md new file mode 100644 index 0000000000..4a657b2418 --- /dev/null +++ b/Specialized Areas/Fix scripts/Create Table JSON/README.md @@ -0,0 +1,3 @@ +This Fix script will create JSON of all or specified fields of a table. +The developer need to pass the table and and fieldnames to function. If no field name is specified, the JSON will contain all fields of table. +This will be helpful incase of inbound integrations where the third part application needs JSON format of table. diff --git a/Specialized Areas/Fix scripts/Create Table JSON/script.js b/Specialized Areas/Fix scripts/Create Table JSON/script.js new file mode 100644 index 0000000000..1ecd6e64e2 --- /dev/null +++ b/Specialized Areas/Fix scripts/Create Table JSON/script.js @@ -0,0 +1,12 @@ +getJson('incident', 'rfc,caller_id'); // pass table name and field names comma separated. +function getJson(tableName, fields) { + var jsonObj = {}; + var eQry = gs.nil(fields) ? 'name=' + tableName : 'name=' + tableName + '^elementIN' + fields; // generate JSON of enitre table if no fields are specified. + var dict = new GlideRecord('sys_dictionary'); + dict.addEncodedQuery(eQry); + dict.query(); + while (dict.next()) { + jsonObj[dict.element] = ''; + } + return JSON.stringify(jsonObj); +}