How to create an event in run script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 12:57 PM
How do I create an event using an script in run script? I want to be able to create an event to create a notification for each person I want to send it to.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 12:55 AM
Priya R wrote:
You can write the logic in the script based on your needs.
.. or you can create a notification, rather than write a script.
Scripting should be avoided where possible, unless the provided methods are unsuitable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 01:02 AM
My bad, I have gone with script action logic instead of email notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 01:11 AM
.. which is still a valid approach, but for emails a quicker route is the notifications.
(you'll be surprised at the number of times I've seen people script an email notification through Script Actions as an event response!)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 10:45 AM
Thank you for all your responses! You guys are helpful!
I was able to create an event. I used the following line of code inside of my "run script" to create the event.
gs.eventQueue("arp_order_circuit", current , current.sys_id , current.sys_id);
Now I need to write code in my run script so that the owner group will receive the event. So I need to create an event for each separate recipient so that a notification gets created for each.
In my form I have a reference field in which the user will select the CI.
After he selects the CI. We will send a notification to the owner of the CI (recipients). For example the user select the CI called WAM, so in this case we will notify the following recipients (yellow marker).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 12:16 PM
So I tried this but still not working....it creates an event but it never sends the notification
var groupID = current.impacted_ci_first.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("catalog.opening.dns.notification", current, userList.join(','), '');