- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 01:55 PM
I have a table with column type of "List" which refers to another table. I use below script to add some values by script but it is not working. I also tried with push but still not working.
FYI: u_list_service_id is a List type referring to another table.
var arr2 = [];
arr2.push('1ced6d77876f4950cb9fda4e3fbb35f8');
arr2.push('58ed6d77876f4950cb9fda4e3fbb35fd');
var orderItem = new GlideRecord('cmn_location');
orderItem.get('26b4b57f876f4950cb9fda4e3fbb3565');
orderItem.query();
if (orderItem.next()) {
//orderItem.u_list_service_id = ['1ced6d77876f4950cb9fda4e3fbb35f8','58ed6d77876f4950cb9fda4e3fbb35fd'];
orderItem.u_list_service_id = arr2
//orderItem.u_list_service_id.push('1ced6d77876f4950cb9fda4e3fbb35f8');
//gs.print(orderItem.u_list_service_id);
orderItem.update();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 01:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 01:58 PM
Try using
arr2.join(',');
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 02:10 PM
Working:
var arr2 = [];
arr2.push('123');
arr2.push('456');
var orderItem = new GlideRecord('cmn_location');
orderItem.get('26b4b57f876f4950cb9fda4e3fbb3565');
orderItem.query();
if (orderItem.next()) {
orderItem.u_list_service_id = arr2.join(',');
orderItem.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 01:25 AM
Awesome!
Glad that it worked out for you
Aman Kumar