- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 03:34 AM
Hi all,
Please see below for our 'Incident Escalated' e-mail, specifically the 'What will it contain' notification details:
* * *
<font face="Calibri">
The following incident has been set to escalated by ${sys_updated_by}:
Customer: ${caller_id}
Updated: ${sys_updated_on}
Priority: ${priority}
Assignment group: ${assignment_group}
Assigned to: ${assigned_to}
Click here to view the incident: ${URI_REF}
* * *
We just want to change this part: The following incident has been set to escalated by ${sys_updated_by}: so instead of showing the user ID of who last updated the record, it shows the name of who last updated it. We have tried dot walking using ${sys_updated_by.name}: but this is not working. I have since realised this is because it is not a reference field back to the sys_user table.
I understand this should be relatively simple so any assistance would be much appreciated.
Many thanks,
D
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 06:59 AM
Hi dasi,
I put in my reply that the script would return the UserID.
It depends what you want to display. If you want the name, you need to do a little more scripting, and use the mail script as proposed by Sanjeev Kumar above, edited to suit your needs. I've added comments in Blue.
- <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>
Best to remove the comments before adding to your email. This has been tested and works fine on my instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 09:58 AM
Once again, thanks for the help guys... so using the script in post 14 I have now been able to get the name populating as required (instead of ID).
Just out of interest what is the difference between this script and the original one in post 9 as when I tried that script it brought back the name (instead of ID) but of a completely random (and non-ITIL) user! Any ideas!?
I was confused by the talk of getDisplayValue() as I always had the ID populating from just current.sys_updated_by but looks like I got there eventually!
Thanks all!
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 10:04 AM
Sorry but just trying to further my understanding, please can you explain what this part of the script is doing in detail if possible:
- gr.query();
- if (gr.next()) { // If it finds one....
Cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 10:06 AM
the "gr.query()" is actually executing the query. That will result in a potential set of records.
"if (gr.next()){" basically asks the question "does the gr object have any results"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 11:28 AM
Thanks so much for posting, I think it's the first time I've taken a script from the community and had it work without any changes!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 08:46 AM
Hi,
Please help me to call the email script in subject line.