Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

gs.eventQueueScheduled() not working correctly in scoped app

anthony_m
Kilo Contributor

Hi All,

I have a requirement to fire an event which will trigger a script action and SMS reminder prior to the scheduled appointment. Using this as an example https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/integrate/email-integrations/tas...

Now the issue is that when I fire the below event the fifth parameter is not setting the 'process on' field on the event record to the date/time in that field. It fires the event immediately as a result. I note that when I do this in the global scope i.e on the incident record it works to expectations.

gs.eventQueueScheduled("sn_customerservice.reminder",current,gs.getUserID(),gs.getUserName(),current.u_reminder)

Is this a limitation? or do I need to follow some additional steps to get it to work in a scoped app.

Appreciate your comments in advance.

1 ACCEPTED SOLUTION

killswitch1111
ServiceNow Employee
ServiceNow Employee

Anthony,



Looking into a little more on why this is happening, I have a feeling it is an issue with access to the "reminder" field when it is passed in.   But if you generate a new GlideDateTime object and pass it the reminder field, and then pass the new GlideDateTime field to the method, it looks like it works as expected.



var gdt = new GlideDateTime(gr.reminder);


gs.eventQueueScheduled("x_snc_testschedule.test",gr,gs.getUserID(),gs.getUserName(),gdt);



Obviously using "current" instead of "gr" in your situation.



Thanks,


Chris


View solution in original post

2 REPLIES 2

killswitch1111
ServiceNow Employee
ServiceNow Employee

Anthony,



Looking into a little more on why this is happening, I have a feeling it is an issue with access to the "reminder" field when it is passed in.   But if you generate a new GlideDateTime object and pass it the reminder field, and then pass the new GlideDateTime field to the method, it looks like it works as expected.



var gdt = new GlideDateTime(gr.reminder);


gs.eventQueueScheduled("x_snc_testschedule.test",gr,gs.getUserID(),gs.getUserName(),gdt);



Obviously using "current" instead of "gr" in your situation.



Thanks,


Chris


Thanks Chris. Right on the money.