append multiple string fields and copy the value in a glide list field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 04:50 AM
Hi,
i have six string fields in a custom table , all have different group names for each record.And i have field of glide list type. I want to add all the group names in the glide list field. The glide list field is referring the custom group table.(u_sec_grp).
The six string fields and glid list type field is on another custom table(u_div). I want to append all the groups in glide list for each record.
How will i achieve that?
PLease help!
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 08:39 PM
name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 09:40 PM
Hi,
then are you using the correct field name from u_sec_group to query here
updateRecords();
function updateRecords(){
var gr = new GlideRecord('u_div');
gr.query();
while(gr.next()){
var field1 = gr.field1;
var field2 = gr.field2;
var field3 = gr.field3;
var field4 = gr.field4;
var field5 = gr.field5;
var field6 = gr.field6;
var arr = [];
var joinValues = field1 + ',' + field2 + ',' + field3 + ',' + field4 + ',' + field5 + ',' + field6;
var rec = new GlideRecord('u_sec_group');
rec.addQuery('u_name', 'IN', joinValues);
rec.query();
while(rec.next()){
arr.push(rec.getValue('sys_id'));
}
gr.list_field = arr.toString();
gr.setWorkflow(false); // to avoid triggering BR
gr.update();
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 07:04 AM
can you share some screenshots?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 05:15 AM
You can use BR if you want update in backend.
If you want on client side then you can use client script with glideajax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 05:16 AM
Hello,
Please refer sample code.
watch_list is the field type glide_list.
var inc = new GlideRecord('incident');
inc.addQuery('sys_id','f3c0efb41b18c4d0bf60fd13cd4bcb4e');
inc.query();
if(inc.next())
{
inc.watch_list="John"+'\n'+ "Mary";
inc.update();
}