How to write email notification through script and attached to particular notification record?

kinjal1
Kilo Expert

Hi, 

How do I send notification to the user whom I can't access from ' who will receive' in Notification?

If it is through email notification script then which function I use to send email ?

And also how do I attached that script to the particular notification?

 

Thanks,

Kinjal

1 ACCEPTED SOLUTION

The first parameter sent in event is named as param1 and second is named as param2, it's not mandatory to send the param2 always.

If you are sending the recipient in param1 check the param 1 checkbox in notification and if sending recipient in param2 check param 2 checkbox.

Also, It's not going to affect other recipient added on user/group field in notification, it will just add.

View solution in original post

6 REPLIES 6

MS1
Kilo Expert

If this notification is being triggered by an event, it sounds like you will have to use another form of script to set a list of additional users of who you want to add to the "To:" list and pass them into the notification under Event Parm 1 and/or Event Parm 2.

 

 

Event parm 1 contains recipient(Visibile from the Advanced view) Select this check box (true) if the event parameter 1 contains the email recipient. This field is only visible when the Send when field has the value Event is fired.
Event parm 2 contains recipient(Visibile from the Advanced view) Select this check box (true) if the event parameter 2 contains the email recipient. This field is only visible when the Send when field has the value Event is fired.

 

Example:

gs.eventQueue("change.inserted", current, gs.getUserID(), gs.getUserName());

In the above example, the sys_id returned from "gs.getUserID()" is being passed as Parm1 and the "user_name" is passed as Parm2.

You could use the "eventQueue" function to pass another sys_id or email address.

Let me know if this helps and if this answers your question, please make sure to mark your question answered if so..

Chaitanya Redd5
Tera Guru

Hi Kinjal,

If your notification is triggered via event, so you could send the sys_id of recipient as parameter and use the parameter as the recipient of notification. You need to check the Event param 1 contains recipient or Event param 2 contains recipient in the Email notification in "who will receive". Note that these two fields only apperars in advanced view when notification is triggered via event. Please find the below link for reference:

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

 

Also, to use the email script in email notification you need to add ${mail_script:email_script_name} in the Message notification. Please find the below link for email script:

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/script/server-scripting/concept/...

Kindly mark my answer as Correct and Helpful based on the impact.

Regards,

Chaitanya

Hi Chaitanya,

What is the difference between Event param1 and Event param 2?  Both has same description. Which one I select?

And I am already having other recipient on User/Group field as well on 'who will receive'.

 

The first parameter sent in event is named as param1 and second is named as param2, it's not mandatory to send the param2 always.

If you are sending the recipient in param1 check the param 1 checkbox in notification and if sending recipient in param2 check param 2 checkbox.

Also, It's not going to affect other recipient added on user/group field in notification, it will just add.