Set multiple sys_id's to glide_list field

sndev1099
Giga Expert

Hi,

I need to push multiple values to a glide list field. Currently it's only pushing one sys_id and I'm not sure how to push all values from the gliderecord record. Script below:

(function executeRule(current, previous /*null when async*/ ) {

    var entList = [];
    var m2moim = new GlideRecord('x_lbg_insider_risk_insider_access_lookup');
    m2moim.addQuery('sys_id', current.ir_access_categorisation);
    m2moim.query();
	
    while (m2moim.next()) {
		
        entList.push(current.getValue('sys_id'));

		m2moim.u_oim_entitlements = entList.join(',');
		m2moim.update();
	}
		
})(current, previous);

find_real_file.png

5 REPLIES 5

Onkar Pandav
Tera Guru

Hi,

Try writing that join() method line outside the while loop.

Onkar Pandav
Tera Guru

Or try below while loop code:

while (m2moim.next()) {
		
        entList.push(m2moim.getValue('sys_id'));
}
current.u_oim_entitlements = entList.join(',');

Thanks Onkar. Still not working unfortunately. Doing it that way doesn't pass anything into the field

sndev1099
Giga Expert

Thanks Onkar. I think the problem here is that I'm not returning the correct sys_id's. If I add 4 entitlements on my m2m table here:

My log returns 4 entries, but it's the sys_id of that record they sit on 4 times, rather than the 4 different sys_id's of the entitlements above. Hope that makes sense. My query needs to return those 4 sys_ids above and push to glide list field. Can you help?