Adding an "eventQueue" Action to Flow-Designer

Michael_Martin
Tera Contributor

Hi there,
I'm relatively new to ServiceNow, just finished the fundamentals path and I'm on my first project.
I worked as webdeveloper for many years, so I do have a quite good understanding of many programming languages and logics. Only a hard time sometimes to use old javascript, as I've used ES6 a lot and servicenow cannot handle modern stuff ;))

To my issue.
I'm using "Flow Designer" and face a problem here. I need to create an eventQueue that fires and event for sending an email. I don't want to send the email directly in flow, it just should create that queue element for the sysevent table.

For many things there are actions available, but why not for creating an event?
What I want to achieve would be quite easy ..

gs.eventQueue('pfx_time_entries_rejected', Result, Result.u_ts_employee);

Is there an easy way to eventQueue something in Flow Designer or do I actually have to create a record into the sysevent table? Or even worse, write an own action somehow for this simple additional step?

Of course I invested some hours searching for this topic first, before asking here 😉 But, as a new servicenow developer, it can be quite overwhelming finding stuff ;))
I'm also quite surprised that there is no button for a custom action. I mean, every other system does have mostly the ability to add an action with custom code. But here are only predefined actions and not a blank action to write own code.

hope someone can help me.

1 ACCEPTED SOLUTION

Dan H
Tera Guru

Hi Michael,

In Flow designer you can create an action. Give this action the "Run script" and inside of that you can make your eventQueue call.

find_real_file.png

You can test the custom action before saving+publishing.

Once published, from your main flow you can add an action and you will find your custom action in the list.

Alternatively, you don't need to go through all this trouble and instead use the createRecord OOTB action to create a new record for the event.

Useful resource for events/custom actions in flow:

https://community.servicenow.com/community?id=community_article&sys_id=3450a52fdbcf2740afc902d5ca96190b

Hope this helps.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

View solution in original post

7 REPLIES 7

Dan H
Tera Guru

Hi Michael,

In Flow designer you can create an action. Give this action the "Run script" and inside of that you can make your eventQueue call.

find_real_file.png

You can test the custom action before saving+publishing.

Once published, from your main flow you can add an action and you will find your custom action in the list.

Alternatively, you don't need to go through all this trouble and instead use the createRecord OOTB action to create a new record for the event.

Useful resource for events/custom actions in flow:

https://community.servicenow.com/community?id=community_article&sys_id=3450a52fdbcf2740afc902d5ca96190b

Hope this helps.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

OlaN
Giga Sage
Giga Sage

Hi,

There is no need to create a custom action for this.

You can simply use the Create Record action, and choose the syseevent table, and set the event parameters as input to the Create Record action.

find_real_file.png

Is it possible, that it misses one core field?
When I add Name, Table, Parm1, Parm2 it doesnt fire the event.

It does get added to the sysevent table and all looks fine. But the Notification itself, doesnt register that event and doesnt send the mail.

But when I use Scripts -> Background to test it.. gs.eventQueue("....", null, null); it does create the entry as well, but it also does send the mail.

Seems like there is something missing in the background, maybe a secondary entry.
Or maybe its the queue number? Via flow it gets a value of 1. When i use the script debugger, it gets a random number.

Should i set this manually high in the flow?

No, sorry, just a bad example on my end.

You should also set a value in the field called "Instance", which should be a reference to a GlideRecord object.