Triggering custom event from Scripted REST API
This content was last updated in 2023. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 05:58 PM
Hi ,
Can I trigger a custom event from Scripted REST API? Is there nny examples?
Thanks
Raji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 09:25 PM
You use the following script: This is doc for your reference
eventQueue(String name, Object gr, String option1, String option2, String event_queue)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 09:33 PM
HI @Raji9 ,
I trust you are doing great.
Yes, it is possible to trigger a custom event from a Scripted REST API in ServiceNow. To achieve this, you can make use of the GlideSystem's "eventQueue" method. Here's an example code snippet that demonstrates how to trigger a custom event:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
// Your code logic here
// Triggering a custom event
gs.eventQueue('my_custom_event', current, 'additional_data');
// Return the response
return response;
})(request, response);