- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2021 09:39 PM
Hello, I'm not sure what I am missing here. Executing Scheduled Email of Report with below condition script. If I hardcode the grList value, it is working. This schedule is
var answer=false;
var scheduleReport = new GlideRecord('sysauto_report');
scheduleReport.get(current.sys_id); //Sys ID of your schedule Report
var tablename = scheduleReport.report.table;
var query = scheduleReport.report.filter;
var grpList='';
var gr=new GlideRecord(tablename);
gr.addEncodedQuery(query);
gr.query();
while (gr.next()) {
var grp=gr.getValue('assignment_group');
grpList += ',' + grp;
}
//var grList='679434f053231300e321ddeeff7b12d8,8a5055c9c61122780043563ef53438e3';
if (grList.length>0) {
current.group_list=grList;
current.update();
anwswer=true;
}
Thanks, Babeth
Solved! Go to Solution.
- Labels:
-
Reporting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2021 10:45 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2021 10:12 PM
variable answer is not correct , another typo with grpList variable also use grpList as an array to store the value.
Try now
var answer=false;
var scheduleReport = new GlideRecord('sysauto_report');
scheduleReport.get(current.sys_id); //Sys ID of your schedule Report
var tablename = scheduleReport.report.table;
var query = scheduleReport.report.filter;
var grpList=[];
var gr=new GlideRecord(tablename);
gr.addEncodedQuery(query);
gr.query();
while (gr.next()) {
grpList.push(gr.getValue('assignment_group'));
}
if (grpList.length>0) {
current.group_list=grpList;
current.update();
answer=true;
}
Note: If you are using this script in business rule then don't use current.update()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2021 10:21 PM
Copy-pasted the code but no email generated, no error thrown as well. The conditional is also checked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2021 10:26 PM
So this time you are not getting "throwing error: Illegal use of while loop in sandbox scope: org.mozilla.javascript.Parser.whileLoop"
May i know, how are you testing it? if you are checking the condition then no need to use current.update(),
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2021 10:36 PM
Sorry, it has that error. I test by clicking the button Execute Now.