
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 05:12 PM
I want to send an email notification to the owner group of a CI (cmdb_ci).
In my form, I have variable that is a reference to cmdb_ci. If the user selects 'WAM admin', I want to be able to send the email notification to the owner group of thaT ci.
I have an event in my workflow.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2017 08:23 PM
In line 05 there is mem.addQuery... why did you use 'group'.
It says "of all the records in this table, I only want the ones where the group field is the value of groupID (the same as the group in your support group field earlier.)
In line 08...I know you have to push the email members to the array but.. how do you know it will be mem.user.email.toString() ? Like how do you know u have to use user and email?
This is a concept known as dot-walking. It's a way to quickly traverse the relationships of reference fields and tables. I'm building an array of strings (email addresses.) By default, all fields are represented in memory as Javascript objects so I'm converting the email field to a string. That field is coming from the user record that is referenced by the mem record. mem.user is a sys_id to a record on sys_user. sys_user holds a user's profile details. I want the email address. That's what mem.user.email.toString() is doing.
In line 12... could you explain that line to me?
That's the line that actually tells the event engine to queue up the event "catalog.opening.dns.notification". The second parameter is the current record (which is the request item details, the third is your list of email address (converted from an array to a comma separated string), and the fourth is empty.
Events and Email Notifications - ServiceNow Wiki
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 11:01 AM
Sorry to keep asking so many questions...
When you say "Run script", are you referring to a workflow activity? If so, what table is the workflow running on? (Check under the workflow's properties page)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 11:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 11:11 AM
Thank you Claudia. It's probably erroring out and evidence is in the Workflow Log for that context. What you need is something more like this.
var groupID = current.cmdb_ci.support_group.toString();
var userList = [];
var mem = new GlideRecord("sys_user_grmember");
mem.addQuery('group', groupID);
mem.query();
gs.log(mem.getRowCount());
while (mem.next()) {
userList.push(mem.user.email.toString());
}
gs.eventQueue("EVENT-NAME", current, userList.join(','), '');
/////////
Don't forget to register the event in the event registry.
You'll also want to ensure your notification is set to accept the recipients from Event Parm 1
Email Notifications - ServiceNow Wiki
Events and Email Notifications - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 11:40 AM
Chuck Tomasi! Thank you so much for your help. I have struggled a lot!
I checked my event log and I was able to see the event:
I went to my notification and I double checked event parm 1 and 2 are checked:
I went to my outbox to see my notification and I do not see it.
I went to my CI selected : WAM to make sure support_group has an email address attach to...so it does have an email address.
So Im not sure why the notification is not sent to that email :s

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 02:31 PM
Do you have a notification set up to react to the event? The event is simply saying "Here's something to pay attention to if anyone cares." You need to create the notification that says "I care". See the second link I sent earlier how to do that.
It's basically the same thing as a regular notification,but you click the Advanced view link on the notification form and you'll be able to switch the notification trigger from Record Inserted or Updated (on the When to send section) to Event is fired.