The CreatorCon Call for Content is officially open! Get started here.

How to query the list of managers for a user until a director and send them all in CC

SAS21
Tera Guru

In the existing workflow - upon incident creation need to send an email to a submitter and cc all submitter's managers until reaches director. How to achieve this via workflow ?

4 REPLIES 4

Ct111
Tera Sage

i don't know what you mean by band 90, if that means till director or ceo . 

 

You could use below sample code for reference in your scripting section .  However, you would have to modify according to your requirement 

 

 

var userID = current.caller_id; // Get submitter (caller)
var managerEmails = [];

while (userID) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(userID) && userGR.manager) {
var managerGR = new GlideRecord('sys_user');
if (managerGR.get(userGR.manager)) {
// **Modify the stopping condition as needed**
if (managerGR.title == "Director" || managerGR.department == "Executives") break;

managerEmails.push(managerGR.email);
userID = managerGR.sys_id; // Move up the hierarchy
}
} else {
break; // No more managers
}
}

workflow.scratchpad.managerEmails = managerEmails.join(",");

 

 

I hope this helps.

Thankyou for the guidance. Will try this.

Thank you, This is working but need to add all these returned list of managers in 'CC' instead of 'To'  in the workflow event Param1 . 

Check the  below links for reference.

LINK

 

LINK2