- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 04:36 AM
Hello,
We have an Wrapper Function with GlideRecord Query called within a For loop. The GlideRecord Query executes for the first time. However, for subsequent iterations .next(), .has next() returns false.
Any suggestion on using a GlideRecord Query within a for loop will be highly appreciated.
Regards,
Saresh
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 08:20 AM
Saresh,
Use this script
getAffectedClients();
function getAffectedClients(){
var affected_clients = current.u_affected_clients.getDisplayValue();
if(affected_clients.length!=0){//affected clients list
getRelManagers(affected_clients);
}
function getRelManagers(rm_name){
var gr_rm = new GlideRecord('u_rel_mamager_list');
gr_rm.addQuery("u_client_name",'IN', rm_name);
gr_rm.query(); //only first iteration runs successfully
while (gr_rm.next()) { //does not iterate second time gr_rm.next returns false
var rel_manager = gr_rm.getValue('email');
gs.addInfoMessage(rel_manager); //prints only records of first array object
gs.eventQueue("affectedclients.notify", current, rm_name, rel_manager);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 09:03 AM
You can always pass the entire thing and use IN operator in the glideRecord query. You do not need for loop at all.