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.

Queue an event without the 'current' record?

dstuart
Kilo Expert

I'm working on an Inbound Email Action. I have it working, but the person requesting it wants me to 'user-proof' it, i.e. send a "failed" notification with the 'source' email in the event the user specifies some invalid data.

So, I know how to enqueue an event, and send an email notification based on that event. But can I enqueue an event without the 'current' record?

Syntax for gs.eventQueue is gs.eventQueue("event-to-be-queued", current-record, optional-parm-1, optional_parm-2);

Obviously, the event name is mandatory. And it also appears that 'current-record' is also mandatory.

My problem is that since the user had a typo, or otherwise specified some 'invalid' data, the insert of the target record failed. And while there is a sys_id to the 'in-process' record when the gs.eventQueue() runs, when the email notification actually gets around to it, the sys_id is no longer valid, and the email notification fails.

I've tried gs.eventQueue("event-name", , optional-parm-1); but that fails, too, because of what I believe is no 'current record'.

Ideas?

Thanks,

Dave

13 REPLIES 13

It worked!...Thanks a lot ...

Regards,

Snehal Madakatti

Stefan42
Tera Expert

I know it's 3 years ago but you can queue an event without the 'current' record like this:

gs.eventQueue("<Event.name>", "", "", "<parm1>", "<parm2>");

Wanted to thank you for this.  I had tried and abandoned this approach earlier because it was bombing out when trying to pass two event parms.  But I was only passing in 4 arguments in total, kind of like this:

gs.eventQueue("<Event.name>", "", "<parm1>", "<parm2>");

In your approach, you're passing 5 arguments into gs.eventQueue instead.  And though it works, everything I've read suggests this method only accepts 4 parameters.  Do you have any references for what the 5th parameter is?

Sorry Andy, i do not have any references. I'm using this hack/fix for some years now and i don't know if i found it somewhere or if i stumbled on it by accident in trying to achieve this.

There is a risk it will no longer work after future upgrades and patches. But like i said it still works for me after i start using it a few years back.