How to push GlideRecord query to an array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 07:28 AM
How to push GlideRecord query to an array in a Before Query BR
Please find the code below:
I want to push the GlideRecord query to an array.
Note : I have written this code on a Before Query BR
var answer = [];
var grRole = new GlideAggregate('x_amspi_smdrs_app_role_matrix');
grRole.groupBy('site');
grRole.query();
while (grRole.next()) {
var grInp = new GlideRecord('x_amspi_smdrs_app_input_ola');
grInp.addQuery('site', grRole.site);
grInp.addQuery('role', 'DM');
grInp.query();
while (grInp.next()) {
gs.info('check code');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 10:57 PM
@Ian Mildon I am getting error - ArrayUtil undefined, maybe missing global qualifier and this is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 07:48 AM
Try this edited version
getRoleAndSite();
function getRoleAndSite() {
var grRole = new GlideAggregate('x_amspi_smdrs_app_role_matrix');
grRole.groupBy('site');
grRole.query();
var getSite = [];
while (grRole.next()) {
getSite.push(grRole.site.toString());
}
var arrayUtil = new ArrayUtil();
var answer = arrayUtil.unique(getSite)
var grInp = new GlideRecord('x_amspi_smdrs_app_input_ola');
grInp.addQuery('site', 'IN', answer);
grInp.addQuery('role', 'DM');
grInp.query();
while (grInp.next()) {
gs.info('check code');
}
}