We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How can I send weekly scheduled reports to each assignment group DL(Email), ensuring that only their

Chandra31
Tera Contributor

Hi @Sagar Pagar   

I have a requirement to send weekly scheduled reports to each assignment group DL (Email), making sure that only their specific data is included. I tried your existing article , but it sends just one email to all DL addresses with all the data. Can you help with this?

 

Regards,

Chandra

12 REPLIES 12

Hi @Ankur Bawiskar  I tried the code below, but it generated an empty report. I need to send it to the group email instead of the manager. Could you check the code and report conditions as attached below and let me know your suggestions?

 

var gr = new GlideAggregate("change_task");
gr.addQuery("active=true");
gr.groupBy('assignment_group');
gr.query();
var managers = [];
while (gr.next()) {
    managers.push(gr.assignment_group.manager.toString());
}
var testadmin = '67517cfb137e3a0081487e276144b0a9';
var arrayUtil = new ArrayUtil();  
managers = arrayUtil.unique(managers);  

for(var i = 0; i<managers.length; i++){
   
    gs.log('Manager: ' + managers[i]);

    var scheduleReport = new GlideRecord('sysauto_report');
    scheduleReport.get('9575dbdc1b8b3a10b2e3ed34604bcbfa');
    scheduleReport.user_list = managers[i];
    scheduleReport.run_as = testadmin;
    scheduleReport.update();
    SncTriggerSynchronizer.executeNow(scheduleReport);
    gs.sleep(10000);
}

gs.log('Completed');
Chandra31_0-1771322032098.png

 

 

Regards,

Chandra

@Chandra31 

which group email?

For empty report -> do you have records satisfying that condition?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar I would like to send an email to the group distribution list (DL) containing only their relevant data.Can you assist me wit the code and relevent report conditions.

 

Chandra31_0-1771323053927.png

 

Regards,

Chandra

 

@Chandra31 

I think for that already link I shared has logic

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar  Is there another way to accomplish this? My requirement is to send the email to the DL, not the manager.

 

Regards,

Chandra