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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

On which table this notification is present?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Incident [incident]

try:

<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.first_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>

Hi Elijah,

So apart from the script you mention. What do I call from within the email notification itself?

Would it look like this?

 

Dear ${caller_id.name}

Thank you for contacting the 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 +44 (0)1234 5487453 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} 

Sure Systems Administrator

 

As I previously mentioned I'm a novice.. 🙂

 

Pierre