Scheduled reports advanced conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
We have a handful of scheduled reports that have advanced conditions. These conditions have stopped working due to the crack down on sandbox scripts (KB2944435).
We have followed the advice and moved the code to a script include. The function works fine when called from a background script, a business rule and even a UI Action. I have been using script debugger to see when it is triggered and what the variables are. However, it won't trigger from the condition on the scheduled report.
The code we are using is to check if another report (P) has data in it. We only want report (C) to be generated if (P) has data in it. The script include function is as follows:
var My_Report_helper = Class.create();
My_Report_helper.prototype = {
initialize: function() {},
// Check report has data
checkReportData: function(reportSysId) {
var answer = false;
var grReport = new GlideRecord('sys_report');
if (grReport.get(reportSysId)) {
var gr = new GlideRecord(grReport.table);
gr.addEncodedQuery(grReport.filter);
gr.query();
answer = gr.hasNext(); // Only send if main report has data
}
return answer;
},
type: 'My_Report_helper'
};
Calling
new My_Report_helper().checkReportData('1234356789');
in a background script works but it doesn't work in the condition of the scheduled report. It works in background script with Execute in sandbox? checked and unchecked.
I have also tried the following in the scheduled report condition:
My_Report_helper().checkReportData('1234356789');
javascript:new My_Report_helper().checkReportData('1234356789');
But it doesn't seem to trigger the function either. I have tried toggling the Sandbox enabled and Client callable flags on the script include. The script include is in Global and the Accessible from is set to all application scopes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
30m ago
Hello @mrsellicat,
Please refer to the link below:
Exploring Advance Reporting Conditions using Scrip... - ServiceNow Community
If it is helpful, please mark it as helpful and accept the correct solution by referring to this solution in the future it will be helpful to them.
Thanks & Regards,
Abbas Shaik