Scheduled Report - Conditional Script Not Starting at all?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2023 05:25 AM
Good morning community,
I am setting up a simple scheduled report, trying to use a script I found from another post as the conditional script to generate the recipients from running the report query. However, from what I can see, the conditional script is not running. I get no log statements, no nothing unless I manually add a recipient the normal way, and then it only sends to that recipient and still no log statements or.
Does anyone see what I am doing wrong? This is a stale approval report that I want to send to all the people with pending approvals.
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 users = '';
gs.log('JAL ' +tablename + ' ' +query + ' ');
//Execute the report as a GlideRecord with the set table and condition
var gr = new GlideRecord(tablename);
gr.addEncodedQuery(query);
gr.query();
while (gr.next()) {
users += ',' + gr.approver;
gs.log('JAL ' +gr.approver);
current.user_list = users;
current.update();
// Need to set this true for condition script to run
answer = true;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 07:26 AM
I have the same issue...very interested in the answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2023 12:35 PM
No, still no go. I am thinking of tweaking this two a two-stage process. The first, I will strip the conditional script out, edit it a tad, and run that as a SCHEDULED SCRIPT EXECUTION in order to update the SCHEDULED REPORT job, say 15 minute earlier.
Run the script to update the scheduled report recipients 15 mins before scheduled report.
Then run the scheduled report which has updated email recipients.
Finally run a cleanup script 15 mins after the report job to remove all the recipients.
I dont know why it is not working as conditional, but I think we can cheat using a couple scheduled scripts to updated the scheduled job.