how to send all the p1 incidents to manager in email notifications

vajaykumarr
Tera Contributor
 
8 REPLIES 8

Hi @vajaykumarr 

 

https://www.servicenow.com/community/itsm-forum/dynamic-and-individual-emails-based-on-the-report-ou...

 

https://www.servicenow.com/community/itom-forum/using-flow-designer-add-attachment-to-send-email-act...

https://www.youtube.com/watch?v=LIJnhdQBsXw

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************
Topic: On this episode, we will continue to explore what's possible with of dynamic scheduled reports. Stop including extra people on your scheduled reports (you know, just in case!) and only send them to the people, teams, and managers that have items in the report. Crack a beverage and come join

Peter Williams
Kilo Sage

I created a script that would do this for any users that has a pending request for approvals, you could modify this for your need.

execute();

function execute() {
    /* query approval table with GlideAggregate*/
    var approval = new GlideAggregate('sysapproval_approver');
    /* select only requested records */
    approval.addEncodedQuery('state=requested');
    /* group by approver in orer to get unique values (one distinct user at a time) */
    approval.groupBy("approver");
    approval.query();

    while (approval.next()) {
        /* Create a unique Scheduled Report */
        createScheduleReport(approval.approver);
    }
}

function createScheduleReport(user) {
    /* set the appropiate sys_id of your 'Weekly Pending Approvals Report' report */
    var TARGET_REPORT = "ec83ce72933e1e506f7ef36f3bba1080";

    /* create the scheduled report */
    var scheduled_report = new GlideRecord('sysauto_report');
    scheduled_report.initialize();

    /* set all the values */
    scheduled_report.active = true;
    scheduled_report.name = "WeeklyAutoApprovalReminder";
    scheduled_report.run_as = user.getValue("sys_id");
    /* this will replace "is (dynamic) Me" with the real name of the user */
    scheduled_report.user_list = user.getValue("sys_id");
    /* the scheduled report it's unique, hence it should run only once */
    scheduled_report.run_type = 'once';
    //scheduled_report.report_title = "Your Bi-Weekly SE Forms Pending Approval Report";
    scheduled_report.report_title = "SE Forms Pending Approval - Action Required";
    //scheduled_report.report_body ='<p>Hello,</p><p>Find attached your weekly Pending Approvals Report. You can also access the report directly using the link below:</p><p><a href="https://stikemandev.service-now.com/now/nav/ui/classic/params/target/$pa_dashboard.do?sysparm_dashbo...">Click here to view your Weekly Pending Approvals Report</a></p><p>Best regards</p>';
    scheduled_report.report_body ='<p>Hello,</p><p>Find attached your SE Forms Pending Approval Report. Please approve all expenses by January 8th 2025, please email rlobo@stikeman.com if you cannot meet this deadline. You can also access the report directly using the link below:</p><p><a href="https://stikemanprod.service-now.com/now/nav/ui/classic/params/target/$pa_dashboard.do?sysparm_dashb...">Click here to view your SE Forms Pending Approval Report</a></p><p>Best regards</p>';
    scheduled_report.report = TARGET_REPORT;
    scheduled_report.omit_if_no_records = true;
    /* it will attach the records using a spreadsheet attached to the email notification; check the choice list to see other options */
    scheduled_report.output_type = "XLSX";
    var answer = scheduled_report.insert();
}

vajaykumarr
Tera Contributor

sorry guys... i asked the question wrongly...begginers mistake

my question is

How to send all p1 incidents to (manager or assigned group) as daily report by using the flow designer

vishveshpat
Kilo Contributor

 

You have to go to System Notification > Email > Notifications.

Configure the condition: Priority is 1 - Critical

In the 'Who Will Receive section' add the following script:
// Notify assignment group manager
var recipients = [];
if (current.assignment_group.manager) {
recipients.push(current.assignment_group.manager);
}
recipients;