Simon Ohle
Kilo Guru

Fire an event via Flow

Features:

  1. One action for all tables
  2. Select existing events
  3. Easy to use

Backstory: 

Since we fire all our notifications via an event, we have the need to fire events also via "Flows". All research I found was unsatisfactory. It got suggested to create a custom action per table or create a record on the event table. There has also been the request to make this available OOTB (Please upvote).

The main goal of this event is, to be easily and intuitively usable and does what it's supposed to do: Simply fire an event.

Step-by-Step Guide:

  1. Create a new Action
    • Action name: "Fire an event"
    • Application: "Global"
    • Accessible From: "All application scopes"
    • Protection: "None"
    • Category: <your choice>
    • Description: <your description>
  2. Create Inputs
    • Event Name
      • Label: Event Name
      • Name: event_name
      • Type: Reference to Event Registration [sysevent_register]
      • Mandatory: true
    • Event Record
      • Label: Event Record
      • Name: event_record
      • Type: Document ID
        • This reference type is the critical part, which the other solutions missed.
        • It allows to drag & drop any kind of record into the field.
      • Mandatory: true
    • Parm1
      • Label: Parm1
      • Name: parm1
      • Type: String
      • Mandatory: false
    • Parm2 
      • Label: Parm2
      • Name: parm2
      • Type: String
      • Mandatory: false
  3. Add a new Step
    • Script (under Section "Utilities")
    • Required Runtime: Instance
    • Create Input Variables
      • Name: event_name
        • Value: Drag "action > Event Name > Event Name" data pill into the field.
      • Name: event_record
        • Value: Drag "action > Event Record" data pill into the field.
      • Name: parm1
        • Value: Drag "action > Parm1" data pill into the field.
      • Name: parm2
        • Value: Drag "action > Parm2" data pill into the field.
    • Add a script 
      • (function execute(inputs, outputs) {
          gs.eventQueue(inputs.event_name, inputs.event_record, inputs.parm1, inputs.parm2);
         /**
         If the event_log shows "[object GlideRecord]" as the event name use this instead:
         gs.eventQueue(inputs.event_name, inputs.event_record, inputs.parm1, inputs.parm2);
         Thanks to @Monika Bhoyate for pointing it out.
        */
        
        })(inputs, outputs);

         

  4. Save & Publish

Usage:

Drag the Action into your flow and use like any scripted event mechanism.
Make sure you only drag records into the the "Event Record" field

 

find_real_file.png

 

Any questions? Please let me know.

Simon Ohle

 

P.S.: Make sure to upvote the OOTB Feature Idea

Comments
Brady Holliday
Tera Guru

I enjoy seeing how people are making Flow Designer more usable to fit their specific circumstances.

 

An alternative route that I have discovered to trigger notifications within flow designer is to use the OOB 'Send Notification' Action.

  • In order to be able to use this you will need to update the notification records themselves to 'Send When' = 'Triggered'.
    • This will then allow the notification to show up in the dropdown list of that action.

I like the custom action, but just wanted to throw that snippet of information in there for people who might find it helpful.

Simon Ohle
Kilo Guru

Thanks for sharing! I indeed did not know that. 

Simon Ohle
Kilo Guru

Interesting article, thanks for mentioning this article.

Antonio39
Tera Contributor

hi,

first of all, thx for sharing.

Then, I tried your solution but is not working, see attachments.

Am I missing something?

 

thx,

Antonio

 

 

Community Alums
Not applicable

The input type of 'Document ID' requires you select a reference table. Is the idea to select 'Document ID.task'? If yes, wouldn't that only enable it to be used for task extended tables?

Mike Strik
Tera Guru

I tried this, but the option 'Send to event creator' does not seem to work then.

Did this work for you?

 

Thanks.

Simon Ohle
Kilo Guru

Did you try it out? I can drop any record there and dont have to provide a table.

 

find_real_file.png

Monika Bhoyate1
Tera Contributor

Hi Simon,

Thanks for wonderful article. I tried to trigger event "incident.assigned" from flow for "Incident assigned to me" notification. It is firing an event just fine but notification is not getting triggered. In event log it shows [object GlideRecord] as event name, not actual event name. I have attached the snapshot for reference.

Regards,

Monika

Monika Bhoyate1
Tera Contributor

I figured it out! I changed below code:

(function execute(inputs, outputs) {
   gs.eventQueue(inputs.event_name, inputs.event_record, inputs.parm1, inputs.parm2);
})(inputs, outputs);

To:

(function execute(inputs, outputs) {
  gs.eventQueue(inputs.event_name.event_name, inputs.event_record, inputs.parm1, inputs.parm2);
})(inputs, outputs);

Now I am getting event name instead of [object GlideRecord].

Regards,

Monika

Monika Bhoyate1
Tera Contributor

I figured it out! I changed below code:

(function execute(inputs, outputs) {
   gs.eventQueue(inputs.event_name, inputs.event_record, inputs.parm1, inputs.parm2);
})(inputs, outputs);

To:

(function execute(inputs, outputs) {
  gs.eventQueue(inputs.event_name.event_name, inputs.event_record, inputs.parm1, inputs.parm2);
})(inputs, outputs);

Now I am getting event name instead of [object GlideRecord].

Regards,

Monika

Uncle Rob
Kilo Patron

I did something similar that will also let you use gs.eventQueueScheduled if you fill in an additional (datetime) parameter.

Simon Ohle
Kilo Guru

Hi Monika,

thanks for pointing it out. I adjusted my post!

Cheers,
Simon

vishurajm
Tera Contributor

Have you tried this in any scope application ex, HR scope. I am not able to do it or the event does not trigger

Bibeeshmt1
Tera Explorer

Great post, however, do we really need to have reference field to invent registry? I could use string and event name supply to the field should do same magic.. 

Uncle Rob
Kilo Patron

@Bibeeshmt1 - Hadn't considered this but I totally agree.  I can't remember any time I needed access to the event record itself.  Every time I've ever used an event it was for the name only.

Simon Ohle
Kilo Guru

Unfortunately I am not able to update my original post, so here are some adjustments/enhancements, as pointed out by other users:

 

1. As @Bibeeshmt1 mentioned I recommend to not reference the Event Registry, but use "String" Event name as input. Thank you!

1.1 This solves also the work-around in the script, so input.event_name works.

 

2. The Comment in the script with the hint towards @Monika Bhoyate1 s tip also has a spelling error, it has to be

"inputs.event_name.event_name" instead of "inputs.event_name"

2.1 But is not necessary if point one here is used.

VullankiL
Tera Contributor

Hi @Simon Ohle ,

My application is scoped application. It tried this method to fire an event.

But when I am executing the flow, the event is getting fired in event log but with state "error". In the instance field it is taking null, instead of record sys_id. And also not taking URI and parm1.

VullankiL_0-1739859317601.png

while calling this custom action, I have taken event name, event record, and parm1 correctly. I don't know why it is not taking record sys_id and URI. Could you please provide the solution to it..

Thank you

Gary Fawcett1
Tera Guru

This doesn't seem to work in a scope app, the reference table is no longer available.

 

The closest one I found is is UA Event Registry [ua_sysevent_register] in the drop down for Reference.

 

I guess we can script the Fire Event action as above, rather than usinfg the Fire Event action.  Or just write a schedule task rather than a flow.

 

This is using yokohama patch4b in 2025.

Version history
Last update:
‎05-03-2022 02:33 AM
Updated by: