How to display created by name instead of user id in notification

sushmachava
Tera Contributor

 

Hi,

I want to display the name of the created by instead of user id, below script dispalying the user id of the record in the email notification. could you please help me

 

Application ${name} created by ${sys_created_by} with MRC Accreditation ${u_mrc_acc}.

 

 
 

 

1 ACCEPTED SOLUTION

Voona Rohila
Tera Patron

Hi @sushmachava 

You need to query the user table with user id details and get the name.

Write a mail script with below logic and include in body of the notification.

  var grSysUser = new GlideRecord('sys_user');
    grSysUser.addEncodedQuery("user_name=" + current.sys_created_by);
    grSysUser.query();
    if (grSysUser.next())
        template.print("Application" + current.name + "created by " + grSysUser.name + " with MRC Accreditation " + current.u_mrc_acc);

 

Scripting for email notifications 

View solution in original post

3 REPLIES 3

Hemanth M
Tera Sage

Hi @sushmachava ,

 

Created by is a system created (OOB) string field type and populated when record is inserted to database (i wouldn't recommend to change this logic to display Name instead user id)

 

Can you use Opened by instead >> ${opened_by} which gives Name.

 

Thank you,

Hemanth 

Voona Rohila
Tera Patron

Hi @sushmachava 

You need to query the user table with user id details and get the name.

Write a mail script with below logic and include in body of the notification.

  var grSysUser = new GlideRecord('sys_user');
    grSysUser.addEncodedQuery("user_name=" + current.sys_created_by);
    grSysUser.query();
    if (grSysUser.next())
        template.print("Application" + current.name + "created by " + grSysUser.name + " with MRC Accreditation " + current.u_mrc_acc);

 

Scripting for email notifications 

Thanks Voona