Issue in getting all users manager details to trigger a notification

Aditya253
Kilo Guru

Hi All,

 

Actually, I need to send an email notification to the 'assign to' user managers on incident form if the incident state is in progress at every Monday. For this, I have used run script scheduled job in the script I have mentioned the below code. Please help me on this.

 

In the array I am getting repeated email ID's of managers need to remove that, one email is enough to one particular manager. But by using the below code manager receiving emails repeatedly from all incidents. Please help me on this.

 

Scheduled script:

 

var emailList = [];

var incGr = new GlideRecord('incident');

incGr.addQuery('state','3');

incGr.query();

while(incGr.next()){

var userGr = new GlideRecord ('sys_user');

userGr.addQuery('sys_id', incGr.assign_to);

userGr.query();

if(userGr.next()){

var managerEmail = userGr.manager.email;

emailList.push(managerEmail);

gs.event('user_manager_emails', incGr, emailList);

}

}

 

1 ACCEPTED SOLUTION

Thanks you Khushboo

View solution in original post

5 REPLIES 5

Thank you soo much, Martin