Get the first name of the person (agent) who updates the ticket

Pierre5
Kilo Expert

Hi there,

RE: Get the first name of the person (agent) who updates the ticket

I was wondering if anyone could help with the following. (P.S. You are dealing with a complete novice here, just so you know).

We have default emails and custom replies that are sent to 'Callers' (customer). Below is a typical example: (doesn't work)

Dear ${caller_id.name}

Thank you for contacting System Admin Services.

An ticket has been opened, reference number ${number}, and automatically assigned a priority of P${priority}.

If this is a Priority 1 incident telephone the SOC immediately on +47 (0)1539 1234567 and quote the reference number.

Investigation will begin shortly and we will update you throughout the ticket life-cycle. If you would like to post further updates concerning this ticket, please reply to this message.

Regards

${u_updated_by_name} 

Systems Administrator

I followed this article, then lost the plot.

https://community.servicenow.com/community?id=community_question&sys_id=67638b25dbd8dbc01dcaf3231f96...

 

In our replies, I want to include the first name of the agent who updated the ticket. I followed some documentation within 'Community', but couldn't get the name (first name) of the person who updated the ticket. ${u_updated_by_name} 

I created a script as suggested;

<mail_script>  
var userid = current.sys_updated_by;       // Gets the User ID
var gr = new GlideRecord('sys_user');   // Creates new GlideRecord Object
      gr.addQuery('user_name', userid);     // Queries the table for the record of our user found in line 2
      gr.query();  
      if (gr.next()) {                                                                       // If it finds one....
          var userName = gr.name;                           // set the variable "username" as the users name.
        }  
 
template.print("Updated By: "+userName);   // Print the text "Updated By:" and then the username variable from line 7.
</mail_script>

I'm probably way off the mark. Other articles seems to suggest creating a function which references a field, like the one for 'Caller' ${caller_id.name}... However!,  there's no field in my user case for the agent (person updating the ticket). If that is the case, then I guess I would need to add a field for the agent name, then hide it.

I though this would be an easy task, but finding really difficult to achieve. In a nutshell, all I want is the agents first name to be included with the signature.. Eg;

Regards,

Pierre

Systems Administrator

10 REPLIES 10

It would be ${name_of_mail_script} but the following should work as well: 

find_real_file.png

Omkar Mone
Mega Sage

Hi 

You can try with ${caller_id.first_name}

 

Hope this helps.

 

Regards,

Omkar Mone

Thanks Omkar,

So is it just a case of adding ${caller_id.first_name} like this?

find_real_file.png

 

Kind regards,

Pierre

Hi Pierre

 

Yes that way, did it help?

 

Regards,

Omkar Moe

vkachineni
Kilo Sage
Kilo Sage
<mail_script>  
var userid = current.sys_updated_by;       // Gets the User Sys ID
var userName = '';
var gr = new GlideRecord('sys_user');   // Creates new GlideRecord Object
      gr.addQuery('sys_id', userid);     // Queries the table for the record of our user found in line 2
      gr.query();  
      if (gr.next()) {                                                                       // If it finds one....
          userName = gr.first_name;                           // set the variable "username" as the users first_name.
        }  
 
template.print("Updated By: "+ userName);   // Print the text "Updated By:" and then the username variable from line 7.
</mail_script>
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022