How to send delegated person email if user optied for delgation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 02:15 AM
I am integrating with third party for decision making as part of it I am sending the decision makers emails to them so that power automate will send the notification to them.
But what if the decision maker is already opted delegation then I should send delegate person mail instead original??
I also have another edge case what if the person opted delegation once after request already sent to power automate??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 01:51 AM
Thank you for marking my response as helpful.
The script is easy.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 02:12 AM
something like this but please enhance
// Check for active delegation
var recipientUserId = 'user_sys_id'; // Replace with target user's Sys ID
var grDelegate = new GlideRecord('sys_user_delegate');
grDelegate.addQuery('user', recipientUserId);
grDelegate.addQuery('assignments', true); // Check if assignments are delegated
grDelegate.addEncodedQuery('ends>javascript:gs.daysAgoEnd(0)'); // Active end date
grDelegate.query();
if (grDelegate.next()) {
var delegateUserId = grDelegate.getValue('delegate');
// now you have delegate user sysId
// you can use gs.eventQueue() to send email to that or use API
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 03:52 AM
If I'm not mistaken, once a delegation is given, the delegatee receives all the emails. This is my understanding, but only for new records. To test this:
Create a delegation in your instance, create a new record, and assign it to the user. Then, check if the delegatee is receiving the email. If yes, no further confirmation is required.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 03:10 AM
Actually for the approvals we are sending team notifications/outlook mails to approvers via power automate before sending them we are not validating whether he opted delegation or not but now we need to check if he not opted delegation then we can send his details directly to the power automate but if he opted delegation I need to send delegated person details if the trigger is happening with in the delegation duration.
How can we achieve this through script?
Even if we achieve this through script sometimes approver might opt delegation once he got the approval notification? can we address this through script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 03:41 AM
In this case, you need to check two things:
-
Go to the delegation table.
-
Verify if the user record is present.
-
If yes, check the start date and end date, and compare them with the current date.
-
Then check if the notification has been triggered (ticket created or not).
-
Finally, retrieve the delegate's name.
-
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************