Fire an event via Flow: Custom Action Guide (Any Table)
- One action for all tables
- Select existing events
- Easy to use
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:
- Create a new Action
- * Action name: "Fire an event"
- Application: "Global"
- Accessible From: "All application scopes"
- Protection: "None"
- Category:
- Description:
- Application: "Global"
- Create Inputs
- 1. * Label: Event Name
* Name: event_name
* Type: Reference to Event Registration [sysevent_register]
* Mandatory: true
- * 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
- Name: event_record
- Parm1
- * Label: Parm1
- Name: parm1
- Type: String
- Mandatory: false
- Name: parm1
- Parm2
- * Label: Parm2
- Name: parm2
- Type: String
- Mandatory: false
- Name: parm2
- * Label: Event Record
- 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.
- * Value: Drag "action > Event Name > Event Name" data pill into the field.
- *
(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);
- Required Runtime: Instance
- 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
Any questions? Please let me know.
Simon Ohle
P.S.: Make sure to upvote the OOTB Feature Idea
Labels:
https://www.servicenow.com/community/now-platform-articles/fire-an-event-via-flow-custom-action-guide-any-table/ta-p/2312357
