Scripted notification recipients

xiaix
Tera Guru

I have a Notification record on the incident table:

find_real_file.png

 

I want to script the recipient list "Who will receive". 

find_real_file.png

 

How can I script the recipient list?

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

I believe you would have to change send when drop down to  an event is triggered.  An then use a business rule to trigger the event and then on the who will receive  there should be a check box "Event parm 1 contains recipient".  Then and determine in you business rule who will get it and use gs.eventQueue to fire the event.

gs.eventQueue('Event Name', current, list of recipients);

View solution in original post

16 REPLIES 16

Chuck Tomasi
Tera Patron

You can add a script to your message body with the tag:

${mail_script:scriptname}

See this for more information

Scripting for email notifications | ServiceNow Docs

The scripting API includes an email object that you can several methods described here

Mail script API | ServiceNow Docs

felladin
Tera Guru

Hello,

Trigger the notification through an event instead.
Then you can send the recipients as a parameter and script them in the script that triggers the event.

https://community.servicenow.com/community?id=community_article&sys_id=054deee5dbd0dbc01dcaf3231f961912

Either add the recipients in a Mail Script, or have one of the Event Parms having a comma separated list of recipients and set that parameter in your Notification to contain recipients.

With regards
Anton

Brian Lancaster
Tera Sage

I believe you would have to change send when drop down to  an event is triggered.  An then use a business rule to trigger the event and then on the who will receive  there should be a check box "Event parm 1 contains recipient".  Then and determine in you business rule who will get it and use gs.eventQueue to fire the event.

gs.eventQueue('Event Name', current, list of recipients);

That "event" doc link is incredibly confusing because if you follow the steps, nothing works.  That article certainly needs QA'd.  I'll muddle through and try to find examples.

I'm confident this is the route I need to take, but to find decent documentation will take a bit longer. 😉