- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2017 07:23 AM
I have many Scheduled Reports setup; some more complex than others but have hit a snag with scripting conditions so that it only emails the report out to named individuals in the report.
I tried referencing the script from the post here; HELP! How to dynamically set recipients of an existing Scheduled Report to email addresses that are ... but had trouble using this in my report.
This particular report is simple in that it it populates 'x' amount of data grouped by the "Assigned to" on all currently active tickets
My report is defined as......
Instead of the report emailing a distribution list in the "Email Address" field, i just want it to email the contacts that appear in "assigned to" list who do already have an email address attached to their "contact card" in Service Now. I believe a script will achieve this but have no experience writing script.
Any help would be greatly appreciated.
Solved! Go to Solution.
- 4,464 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 03:17 PM
Welcome to the community, James!
After creating your report, pull down the menu and choose "Schedule". Note that you'll want to omit the "Assigned to" query parameter.. we'll take care of that later in our script:
Then on the resulting page, click the "Conditional" box, and a script area shows up. Taking the suggested script from the other thread you referenced, paste it in the script area:
Here's the script that should work for you:
answer = lookupUsersAndUpdateReport();
function lookupUsersAndUpdateReport(){
// look up "assigned_to" people -- assumes "table" is task-based
var senderArray = [];
var taskQueryGR = new GlideRecord(current.report.table);
taskQueryGR.addEncodedQuery(current.report.filter);
taskQueryGR.query();
while (taskQueryGR.next()){
senderArray.push(taskQueryGR.assigned_to + '');
}
current.user_list = senderArray.join(',');
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
// only return true if there were records listed in the result set
if (senderArray.length > 0){
return true;
}
return false;
}
..And that should do it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2025 12:56 AM
I have done the same for incident table but dint get this to work, because i cannot see this in To field on outlook but only can see the users which i have added manually. Will this only work without putting user and group field on scheduled report? please confirm