Triggering custom event from Scripted REST API
- 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);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi