append multiple string fields and copy the value in a glide list field

SK41
Giga Guru

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

14 REPLIES 14

name

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

can you share some screenshots?

Pranesh072
Mega Sage
Mega Sage

You can use BR if you want update in backend.

If you want on client side then you can use client script with glideajax.

LAXMI TODAKAR2
Tera Contributor

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();
}