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-27-2017 01:51 PM
Generally, you'd raise the event and pass the sys_id of the record you're interested in.
Then you'd create a response against this event which uses the sys_id to identify the appropriate record, bringing out record attributes as you see fit.
Normally you'd not try to pass all the info as a parameter - treat the record as an object and pass a reference to it.
For what it's worth, this is exactly the topic we cover on our Script course: Scripting in ServiceNow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 02:05 PM
Yeah I would love to take the course but it is out of my budget. So I am trying lo learn by my own.
I used gs.eventQueue("catalog.opening.dns.notification", current, email_id, email_id); to create an event but it doesn't create the event 😕
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 02:09 PM
I used gs.eventQueue("catalog.opening.dns.notification", current, email_id, email_id); to create an event but it doesn't create the event 😕
Did you register this event?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 02:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 02:29 PM
Can you do gs.eventQueue("catalog.opening.dns.notification", current, current.cmdb_ci.owned_by, email_id);
It should still fire the event. You can do a gs.log(current.number) to see that it is in the run script portion.