- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2024 11:47 AM
hello,
I have a report which has a an email field.
I need to pull unique email ids from this report and put on to the TO field of the scheduled email of the report.
I have this script written in the condition part of the Scheduled job. When executed, the To does not seem to populate.
Could you please let me know what is that missing in the script or what is the best way to populate the email Ids on to the email to send the report.
Script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2024 12:59 PM
Hi @Shree Nag ,
Please try below approach if possible:
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!
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2024 12:59 PM
Hi @Shree Nag ,
Please try below approach if possible:
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!
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda