- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 03:48 AM
Hi,
I need to push multiple values into a glide list field from records retrieved from gliderecord. Currently it's only pushing one value. Is there something simple I'm missing? I've logged it and the glide record is returning 5 records.
(function executeRule(current, previous /*null when async*/) {
var m2moim = new GlideRecord('x_lbg_insider_risk_m2m_catalog_acce_ir_access_ca');
m2moim.addQuery('ir_access_categorisation', current.sys_id);
m2moim.query();
while (m2moim.next()) {
//gs.info("AB 28_07 " + m2moim.sys_id);
var entList = [];
entList.push(m2moim.catalog_access);
current.u_oim_entitlements = entList.toString();
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 05:44 AM
Hello Brack,
Below please find the updated working code.
(function executeRule(current, previous /*null when async*/) {
var entList = [];
var m2Gr = new GlideRecord('x_lbg_insider_risk_m2m_catalog_acce_ir_access_ca');
m2Gr.addQuery('ir_access_categorisation', current.sys_id);
m2Gr.query();
while (m2Gr.next()) {
entList.push(m2Gr.catalog_access.toString());
}
current.u_oim_entitlements = entList.join();
})(current, previous);
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 04:50 AM
Hi Bracken,
Did you check the rowCount for that query?
If it is giving more than 1 then array should hold multiple values
Check what comes in log
(function executeRule(current, previous /*null when async*/) {
var m2moim = new GlideRecord('x_lbg_insider_risk_m2m_catalog_acce_ir_access_ca');
m2moim.addQuery('ir_access_categorisation', current.sys_id);
m2moim.query();
gs.info('Row Count is:' + m2moim.getRowCount());
while (m2moim.next()) {
//gs.info("AB 28_07 " + m2moim.sys_id);
var entList = [];
entList.push(m2moim.catalog_access.toString());
}
current.u_oim_entitlements = entList.toString(); // this line outside the while loop
})(current, previous);
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
07-28-2020 05:44 AM
Hello Brack,
Below please find the updated working code.
(function executeRule(current, previous /*null when async*/) {
var entList = [];
var m2Gr = new GlideRecord('x_lbg_insider_risk_m2m_catalog_acce_ir_access_ca');
m2Gr.addQuery('ir_access_categorisation', current.sys_id);
m2Gr.query();
while (m2Gr.next()) {
entList.push(m2Gr.catalog_access.toString());
}
current.u_oim_entitlements = entList.join();
})(current, previous);
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 06:11 AM
Perfect, thanks a lot Pradeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 06:17 AM
You are very welcome
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 04:22 AM
Hi
This has slightly changed and I'm now running the business rule on the table where I was orginally doing a gliderecord to. Using the same code, I changed a few things round but now isn't working. Can you help me understand where I'm going wrong please? The log finds the records so it's just a case of pushing them to the field.
(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.catalog_access.toString());
}
m2moim.u_oim_entitlements = entList.join();
})(current, previous);