How to get the Parent record created by NAME on Email body using notification script

Rajesh Bandila
Tera Contributor

Hi Everyone,

 

I have any requirement to get the parent record Created By NAME(i,e sys_created_by) on notification body by using email notification script. Notification triggered on child table. I have coded the below lines of script and it's getting current(child) table created by value. how to get the parent record created by name?

 

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',parent.sys_created_by);
gr.query();
if(gr.next()){
   template.print(gr.name);
}
 
Thanks,
Rajesh Bandila
1 REPLY 1

Mark Manders
Mega Patron

sys_created_by isn't a reference field, so why not query to the parent record directly instead of going through the sys_user table?

 

template.print(gs.getUser().getUserByID(parent.sys_created_by).getDisplayName());


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark