Getting Managers and adding them in cc

SAS21
Tera Guru

trying to get the managers list from script include and adding all of them in cc in notifications email script.

have list of event mappers. need to check if one of the event matches from the event mapper then execute the below. But its not executing. Appreciate the help.

if (eventMapper[event.name] == 'x_is_ma.create_request') {
var managersList = [];
if (current.u_submitt_on_behalf_of_email == '') {
managersList = utils.getManagersEmails(current.u_submitter_name.sys_id);
for (var i = 0; i < managersList.length; i++) {
email.addAddress("cc", managersList[i]);
}
}
}

1 ACCEPTED SOLUTION

@SAS21 

query sys_user with that email and pass the 3rd parameter as the manager name

are you sure it's getting inside this IF?

managersList = utils.getManagersEmails(current.u_submitter_name.sys_id);

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

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@SAS21 

email.addAddress requires 1 more parameter i.e. 3rd one which is display name

what does that array contain?

If it contains sysId then query sys_user with that and get the email and display name

Can you share the complete script here?

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

@Ankur Bawiskar

Hi,

getManagersEmails function is returning all the list of managers emails from the script include . but the only problem is with the line email.addAddress("cc", managersList[i]);  can u guide what is missing here ? 

@SAS21 

what does that array contain?

does it contain sysId or email of that manager?

I already told if it's sysId then query user table and get the email and display name and set like this

email.addAddress('cc', 'email', 'displayName');

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

@Ankur Bawiskar  array has the list of email ids .