- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 11:45 AM
I have requirement where I am triggering the event using gs.eventQueue but it is not working as expected.
// Check if a specific condition is met (e.g., a field is updated)
if (current.active != previous.active) { // Example: Trigger when 'active' changes
var eventName = "user_status_changed"; // Define your custom event name
var parm1 = current.sys_id; // First parameter for the event
var parm2 = current.active; // Second parameter for the event
// Trigger the event
gs.eventQueue(eventName, current, parm1);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:25 AM
Hi jamesmig,
Your event is not getting triggered because you are missing on one more parameter. Please see below the syntax of gs.eventQueue api.
gs.eventQueue('event_name', gliderecord_object, 'string_parm1', 'string_param2', 'string_queue')
Fifth parameter being used for custom queue. But if you want you can skip one of the string_params and then it should work
gs.eventQueue(eventName, current, parm1, parm2);
//if you want to not have value then you can do as shown below
gs.eventQueue(eventName, current, parm1, ''); //i.e. empty string instead parm2
Mark my response helpful if it really helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 07:04 PM
As per new community feature you can mark multiple responses as correct.
If my response helped please mark it correct as well so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:25 AM
Hi jamesmig,
Your event is not getting triggered because you are missing on one more parameter. Please see below the syntax of gs.eventQueue api.
gs.eventQueue('event_name', gliderecord_object, 'string_parm1', 'string_param2', 'string_queue')
Fifth parameter being used for custom queue. But if you want you can skip one of the string_params and then it should work
gs.eventQueue(eventName, current, parm1, parm2);
//if you want to not have value then you can do as shown below
gs.eventQueue(eventName, current, parm1, ''); //i.e. empty string instead parm2
Mark my response helpful if it really helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:42 AM
for what purpose you are triggering the event? this event is tied with email notification or some script action
would like to understand your business requirement here
seems your IF condition is not satisfying, Did you print current.active and previous.active in logs?
Rather than checking it in script why not use BR condition for the active flag?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:54 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:45 AM
Was trying around BR but it was not getting triggered thanks for the response though