How to sent a notification to inform Group Manager to review their groups for user membership

Sanjay33
Tera Contributor

Hi Team,

How to sent a notification to inform Group Manager on every 2nd Wednesday by 8 AM in September every year.

Kindly help me on the same.

 

Thank you.

18 REPLIES 18

Ankur Bawiskar
Tera Patron
Tera Patron

@Sanjay33 

you can use daily scheduled job at 8AM and see if it's 2nd Wednesday of that month

something like this

Scheduled Job Condition - First Monday of Every Month 

How to schedule incident every Third Tuesday of each month??? I tried doing it by "Scheduler" and Tr... 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Sanjay33 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar,

 

I am using below script to mail to manager and deputy manager(custom field in group table), below code is triggering an email to managers and deputy managers.

 

Schedule job Condition:

var date = GlideDate();
var month = date.getMonth();
//gs.print(month);
if (month == 3 || month == 9) {
    //if ((day > 7 && day <= 14) && date.getDayOfWeek() == 3);
    //if (date.getDayOfWeek() == 5)
    gs.log('Today is Friday');
        answer = true;
} else {
    answer = false;
}
 
Script:
var arr = [];
var brr = [];
var grp = new GlideRecord('sys_user_group');
grp.addEncodedQuery('manager!=NULL^active=true^u_deputy_manager!=NULL');
grp.query();
while (grp.next()) {
    var managersemails = grp.manager.email;
    var deputymanageremails = grp.u_deputy_manager.email;
    arr.push(managersemails);
    brr.push(deputymanageremails);
}
gs.eventQueue('send.manager.deputymanager.membership', grp, arr,brr);
 
But I require, I should only add one person in 'to'(in the notification) same way it have to trigger all the managers and deputies.
 
Kindly help me with the code.
 
Thank you.

@Sanjay33 

so you want separate email for each manager and deputy manager?

if yes then do this

var arr = [];
var brr = [];
var grp = new GlideRecord('sys_user_group');
grp.addEncodedQuery('manager!=NULL^active=true^u_deputy_manager!=NULL');
grp.query();
while (grp.next()) {
    var managersemails = grp.manager.email;
    var deputymanageremails = grp.u_deputy_manager.email;
    arr.push(managersemails);
    brr.push(deputymanageremails);
}

// ensure you set event parm1 contains recipient in the notification
for (var i in arr)
    gs.eventQueue('send.manager.deputymanager.membership', grp, arr[i].toString());

for (var j in brr)
    gs.eventQueue('send.manager.deputymanager.membership', grp, brr[j].toString());

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

No, If any user is in manager or deputy, we need to send only one email. If we use array like this all managers and deputy manager will include in same mail.

 

We should send a one mail, to the managers / Deputy managers, In the group table even if one is Manager or Deputy Manager for many groups.