ServiceNow Learning 36: Sending Scheduled Reporting to dynamic users in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 06:10 AM - edited 05-22-2025 12:38 AM
Hi All,
Here is very common requirement wherein we need to send the scheduled report to dynamic users and that too multiple users.
So, the best option to achieve this requirement would be create one Scheduled Report and one Scheduled Job which helps us to update the dynamic users via script in Scheduled Job.
Here is the great example to achieve this.:
I think it will help community users to work on this type of requirement in the future.
Create a scheduled report which will trigger based on conditions and send it to the dynamic receipts. Dynamic recipients may be assigned to users, the assignee’s manager, etc.
Use cases:
- Create a scheduled report which will trigger based on some conditions and send it to dynamically assigned to users.
- Create a scheduled report which will trigger with conditions and send the incidents report to Managers of the assignment group.
- Create a scheduled report to send to the assigned_to users and his/her managers for pending approval of requests.
Here is the script:
updateDynamicRecipients(); function updateDynamicRecipients(){ var scheduleReport = new GlideRecord('sysauto_report'); // glide the Scheduled report scheduleReport.get("sys_id of report"); //Sys ID of your schedule Report var recipients = []; var tablename = scheduleReport.report.table; var query = scheduleReport.report.filter; var gr = new GlideRecord(tablename); gr.addEncodedQuery(query); gr.query(); while (gr.next()) { recipients.push(gr.assigned_to.sys_id.toString()); // push the assigned _to users in recipients array } // gs.log(recipients.toString()); // gs.log(recipientsManager.toString()); var arrayUtil = new ArrayUtil(); finalRecipients = arrayUtil.unique(recipients); // unique elements scheduleReport.user_list = finalRecipients.join(','); // gs.log("User list: " +current.user_list); scheduleReport.update(); SncTriggerSynchronizer.executeNow(scheduleReport); //execute schedule report }
I found this article very helpful. I followed the steps and able to resolve my real time problem.
Regards,
Shamma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 04:34 AM
Looks like content from an older community post:
https://www.servicenow.com/community/platform-analytics-articles/scheduling-a-report-for-dynamic-rec...