Email Notification Script Question - on where event.parm1 comes from

Steve42
Tera Expert

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.

1 ACCEPTED SOLUTION

Pranav Bhagat
Kilo Sage

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}

View solution in original post

5 REPLIES 5

Ahmmed Ali
Mega Sage

Hello, 

 

for each event, there will be two parameters which you can add to use the data in any script later point.

the API to trigger event in servicenow is

gs.eventQueue("event_name", GlideRecord object of current record, parm1, parm2);

Here parm1 and parm2 are string parameters which you can use in notification or email script.

To find what value is being set in parm1 in your event, you can go to business rule and set condition as script contains your event name.
in script event trigger statement, verify what is being set in third argument for the eventQueue().
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali