Event Queue is not getting triggered

jamesmig_0007
Tera Contributor

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);
2 ACCEPTED SOLUTIONS

maheshkhatal
Mega Sage

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.

View solution in original post

@jamesmig_0007 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

maheshkhatal
Mega Sage

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.

Ankur Bawiskar
Tera Patron
Tera Patron

@jamesmig_0007 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@jamesmig_0007 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

jamesmig_0007
Tera Contributor

Was trying around BR but it was not getting triggered thanks for the response though