How to get "updated by " name in the notifications?

sowmyab
Giga Contributor

By using this " ${sys_updated_by} " i'm getting the user id of the user in the notifications.

But i want updated User name not the user id, can any one knows how can we achieve this?

4 REPLIES 4

Siddartha Gudim
Tera Guru

use can solve this by using email script


add this to notification


${mail_script:updated_by}




create a mail script by name me updated_by




(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


                  /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


                  /* Optional GlideRecord */ event) {



var gr = new GlideRecord('sys_user');


gr.addQuery('user_id',current.sys_updated_by);


gr.query();


while(gr.next())


{


template.print(gr.name);


}




})(current, template, email, email_action, event);




We are employing this method as updated by field is of type string



Please like or mark correct based on the impact of response.



Thank you


Otmane FARAJ
Tera Contributor

Hi,


You can use mail script,



1 - Put this in the notification HTML :


${mail_script:getUpdatedBy}




2 - Add a new mail script with the name getUpdatedBy and paste this code in script field :



(function runMailScript(current, template, email, email_action, event) {



                var gr = new GlideRecord('sys_user');


                  gr.get(current.sys_updated_by);


            template.print(gr.name);



})(current, template, email, email_action, event);



Regards,


Otmane


Thota Naga Jyo1
Tera Contributor

use this script its working for me

var gr = new GlideRecord('sys_user');

     gr.addQuery('user_name',current.sys_updated_by);
gr.query();
if(gr.next()){

   template.print(gr.name);