- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 08:19 AM
I'm looking at an email notification for outbound communication that when a case is commented - internal I click the show Notification Scripts, then in there there are two script the one I am looking at is user_name that has the following script
var userid = event.parm1;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', userid);
gr.query();
if (gr.next()) {
var userName = gr.name;
}
template.print("updated by "+userName);
email.setSubject(current.sys_class_name.getDisplayValue() +' '+ current.number + ' was updated by '+userName);
The problem is when I get updates, sometimes I am getting random stuff like '*updated by <Domain> System Scheduler update... or undefined or a totally random name.
I think it's because the user it needs to be the current user that updated the incident something like current.user.
also i'm trying to figure out what event.parm1 really is, the person that wrote this script is no longer with the company and we need to get this fixed as it's really annoying and confusing customers and internal folks as well.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 08:26 AM
event.parm1 or 2 : you can send parameters from the task to the email notification using these to values.
Basically they come when you use event based notification .
For issue with the random name, can you share more details on it (maybe some screenshots)
Detailed Explanation of event.parm1
For example, you can send the ticket's number, or assigned to, or comments, depends on what you need.
Example:
In a business rule, you can add this code :
gs.eventQueue('incident.manager.reminder', current, current.number, gs.getUserName());
//gs.eventQueue - adds an event to System Logs -> Events
//incident.manager.reminder - is the name of the event
//current.number - refers to the number of the task the business rule is running on - this is parm1
//gs.getUserName() - gets the username of the one who generated the event - this is parm 2
So when you open the event in System Logs -> Events, you can see parm1 and parm2, such as INC00**** and <name>, respectively.
You can then use the events in an email notification:
If you send the recipient in parm1, you can check in tab "Who will receive" Event parm 1 contains recipient.
Or you can use it inside the notification itself: ${event.parm1}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 08:26 AM
event.parm1 or 2 : you can send parameters from the task to the email notification using these to values.
Basically they come when you use event based notification .
For issue with the random name, can you share more details on it (maybe some screenshots)
Detailed Explanation of event.parm1
For example, you can send the ticket's number, or assigned to, or comments, depends on what you need.
Example:
In a business rule, you can add this code :
gs.eventQueue('incident.manager.reminder', current, current.number, gs.getUserName());
//gs.eventQueue - adds an event to System Logs -> Events
//incident.manager.reminder - is the name of the event
//current.number - refers to the number of the task the business rule is running on - this is parm1
//gs.getUserName() - gets the username of the one who generated the event - this is parm 2
So when you open the event in System Logs -> Events, you can see parm1 and parm2, such as INC00**** and <name>, respectively.
You can then use the events in an email notification:
If you send the recipient in parm1, you can check in tab "Who will receive" Event parm 1 contains recipient.
Or you can use it inside the notification itself: ${event.parm1}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 08:34 AM
Hi Steve
Any Update on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 08:27 AM
event.parm1 and event.parm2 originate from the sysevent table for the event that triggers the notification. They are typically assigned via gs.eventQueue() - see https://developer.servicenow.com/dev.do#!/learn/learning-plans/paris/new_to_servicenow/app_store_lea...
Also, for a JavaScript best practice, never use variables in scenarios where they can be undefined. In your case, this would mean either declaring the variable "userName" BEFORE your conditional, or putting your template.print() and email.setSubject() calls WITHIN the conditional. I believe the latter of which will solve your current issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 08:28 AM
Hi,
if you are triggering event via gs.eventQueue() then event.parm1 will be containing the recipient sys_id i.e. what is used in the query against the sys_id field
you can send data through those parameters and access in the email scripts
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader