How to get previous manager value in Email Notification body?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 06:49 AM
Hi ,
I have a requirement to show previous manager's name on notification body where we are using schedule job to trigger the notification and update the group record with manager's manger if user is inactive.
How to show previous manager value, Kindly help!
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 07:09 AM
Hi @Nandini DM ,
Please use this solution :https://www.servicenow.com/community/developer-forum/how-to-get-previous-value-in-email-notification...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 07:25 AM
Hi @Nandini DM
In your scheduled Job, Before updating the group record store the old manager sys_id and pass it in the event as param1 or param2,
In your notification, Make param1 contains recipients as true.
var grSysUserGroup = new GlideRecord('sys_user_group');
grSysUserGroup.addEncodedQuery("manager.active=false");
grSysUserGroup.query();
while (grSysUserGroup.next()) {
var old_manager = grSysUserGroup.manager;
//update logic here.
gs.eventQueue("event.name",grSysUserGroup,old_manager,gs.getUserID()); // pas old_manager sys_id in param1/param2.
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 07:34 AM
Hi there @Nandini DM
Add a custom field to temporarily store the previous manager's name and then, Modify your scheduled job script to save the previous manager's name before updating the manager field. like this below
var gr = new GlideRecord('your_table');
gr.addQuery('condition');
gr.query();
while (gr.next()) {
gr.u_previous_manager = gr.manager.name;
gr.manager = gr.manager.manager;
gr.update();
}
If this helps kindly accept the response thanks.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India