How to create temporary table records using parent array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 12:34 PM
Hi Team,
my requirement is:
I am using rest message and get 3 arrays, and push 3 array to 1 parent array this is working good.
now my challenge is how to create temporary table records using parent array
example:
var responsebody = [];
var response = [{"id":"c5864d0052db4ei0a481bbp0a1892fv8","name":"Test ServiceNow"}]
var response1 = [{"id":"d2454d0052db4ea0a481bbb0a2892fd5","name":"Test ServiceNow1"}]
var response2 = [{"id":"89d5d0052asjdi251bbb0a2asiome9axd3","name":"Test ServiceNow2"}]
responsebody.push(response);
responsebody.push(response1);
responsebody.push(response1);
now how to create temporary table record using "responsebody"
thanks
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 03:43 AM
HI @AnilM99
Or you can optimize the code like this ,
var responseArray = [
{"id":"c5864d0052db4ei0a481bbp0a1892fv8","name":"Test ServiceNow"},
{"id":"d2454d0052db4ea0a481bbb0a2892fd5","name":"Test ServiceNow1"},
{"id":"89d5d0052asjdi251bbb0a2asiome9axd3","name":"Test ServiceNow2"}
];
function createTemporaryRecord(data) {
var tempRecord = new GlideRecord('your_temporary_table_name');
tempRecord.initialize();
tempRecord.setValue('field_name', data.name);
tempRecord.setValue('another_field_name', data.id);
tempRecord.insert();
}
for (var i = 0; i < responseArray.length; i++) {
createTemporaryRecord(responseArray[i]);
}
SS : -
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna