- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 08:05 AM
I am having trouble with a conditional script on a scheduled report, and when I tried to take that out into its own scheduled script, seeing the same issue. I am not able to get past the first log statement- nothing else to go on. What I am doing wrong?
I get the JAL start at the top, but nothing else happens at all. This is a straight scheduled script execution, non-scoped, on demand. Why can I not set a variable or do any normal script things, and cannot even get to the "got here 1" log statement? Thanks!
gs.log('JAL start');
var scheduleReport = new GlideRecord('sysauto_report');
scheduleReport.get(db5dfa1ddbe431102620230bd39619a9); //Sys ID of your schedule Report
gs.log('JAL got here 1');
var tablename = scheduleReport.report.table;
var query = scheduleReport.report.filter;
var users = '';
gs.log('JAL got here 2');
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);
scheduleReport.user_list = users;
scheduleReport.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 08:08 AM
Hi @jlaps,
You forgot quotes around the sys_id:
gs.log('JAL start');
var scheduleReport = new GlideRecord('sysauto_report');
scheduleReport.get('db5dfa1ddbe431102620230bd39619a9'); //Sys ID of your schedule Report
gs.log('JAL got here 1');
var tablename = scheduleReport.report.table;
var query = scheduleReport.report.filter;
var users = '';
gs.log('JAL got here 2');
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);
scheduleReport.user_list = users;
scheduleReport.update();
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 08:08 AM
Hi @jlaps,
You forgot quotes around the sys_id:
gs.log('JAL start');
var scheduleReport = new GlideRecord('sysauto_report');
scheduleReport.get('db5dfa1ddbe431102620230bd39619a9'); //Sys ID of your schedule Report
gs.log('JAL got here 1');
var tablename = scheduleReport.report.table;
var query = scheduleReport.report.filter;
var users = '';
gs.log('JAL got here 2');
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);
scheduleReport.user_list = users;
scheduleReport.update();
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 08:16 AM
Well, that is embarrassing! I had put the sys_id in direct after changing from the conditional script, but I had the same issue there. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 08:17 AM
We all have one of those days sometimes. 😉
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
