How to get previous manager value in Email Notification body?

Nandini DM
Tera Contributor

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

3 REPLIES 3

Community Alums
Not applicable

Voona Rohila
Mega Patron
Mega Patron

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

Its_Azar
Tera Guru
Tera Guru

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.

 

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.




Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG

 Microsoft MVP (AI Services), India