asifnoor
Kilo Patron
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-18-2022 09:03 AM
Hello,
In this article, I will show you how you can take the field columns and its values dynamiclay as key/value pairs.
Here i am using incident table record.
var gr = new GlideRecord("incident");
if(gr.get("57af7aec73d423002728660c4cf6a71c")) {
var arr =[];
var obj;
//this gives us all the column names and its value as key map
for(key in gr) {
obj={};
obj["'"+key+"'"] = gr[key];
arr.push(obj);
}
}
//Now you can send this variable arr to any 3rd party and they can parse it with below code.
for(i=0;i<arr.length;i++) {
for(key in arr[i])
gs.print(key+" "+arr[i][key]);
}
Here is the output.
Hope this helps.
Let me know if you have any questions in the comments below.
Mark the article as helpful and bookmark if you found it useful.
Labels:
- 2,681 Views
Comments
yoli1
Tera Contributor
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
09-21-2023
05:56 AM
Hi @asifnoor how can i match the data from the API to my existing entries in the key-value table cmdb_key_value
Thanks!