How to query the list of managers for a user until a director and send them all in CC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2025 06:05 AM - edited ‎01-31-2025 12:51 AM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2025 06:36 AM - edited ‎01-30-2025 06:36 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2025 06:43 AM
Thankyou for the guidance. Will try this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2025 11:49 PM
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 02:57 AM