Event Actions
Event Actions are a means of triggering an action from an event.
Event Actions are a means of triggering an action from an event.
In Unifi, we throw events for Transaction State changes. Like standard ServiceNow Script Actions, Event Actions respond to those events. Unlike Script Actions, however (where there is a simple one-to-one relationship between the event and the action), Event Actions provide an added level of abstraction in that they offer functionality that enables you to triage the events and make decisions about how you deal with them according to the conditions you configure.
Their primary use case would be in dealing with Transaction errors. For example, you may choose to create an incident after receiving five errors in fifteen minutes, or when a specific error code occurs. The available configuration options make their use case extremely flexible, so you could decide, for example, to auto-close previously opened incidents when the Transaction is complete.
The Event Action executes under the following conditions:
Run Conditions. These stipulate the conditions which cause the Event Action to fire. They specify which Integration* and which Event* the Event Action is responding to (*both Integration & Event are mandatory). They can even be dependent on the status of the integration and apply to specific messages.
Triage Conditions. Triage conditions determine whether or not we take any action i.e. the conditions that must apply for the Action script to run.
Action. This is where you will find the Action script, which is the actual script that will run.
The Details fields that can be configured for the Event Action record are as follows:
Field | Type | Description |
---|---|---|
Name | String | The name of this event action. |
Description | String | An explanation of what the event action is intended to do. |
The Run Conditions fields that can be configured for the Event Action record are as follows:
Field | Type | Description |
---|---|---|
Integration* | Reference | The Integration this action applies to. |
Message | Reference | (Visible when Integration is populated). Only run this Event action for this message. |
Integration status** | Choice | The Integration status this Event Action has to match. (Choices: Up, Down, Ignore) |
Event* | Choice | Which event triggers this Event Action to run. Note, the Triage conditions still need to match as well; this event determines whether the triage conditions are run at all. |
*Integration / Event:
Both Integration & Event are mandatory.
**Integration status:
For example, set the Integration status to ‘Up’ to trigger the Event Action only when the the Integration is Up and use the code in the Script action to set the Integration to ‘Down’. Subsequent Transaction events (triggered whilst the Integration is ‘Down’) would then not cause the Event Action to run, because the run condition would not match.
The Triage Conditions fields that can be configured for the Event Action record are as follows:
Field | Type | Description |
---|---|---|
Advanced | Boolean | Use a script to determine if this Event Action should run. |
Table* | Reference | Table to run a filter against. |
Filter | Condition | The condition used to find matching records, e.g. errored transactions in the last 15 minutes. |
Limit | Integer | The number of records found using the specified filter that will trigger this Event Action’s Action script to be run. Zero will always be true. |
The Action fields that can be configured for the Event Action record are as follows:
Field | Type | Description |
---|---|---|
Action Script | Script | Run this script if the Triage conditions have matched. |
Example script:
Script Variables ****(available in both the Action script and the Advanced Condition script)
current: the current Transaction that triggered the event.
action: the Event Action record (GlideRecord object).
In the above example code, we query the incident table for records that match (using short_description as a unique identifier). If one isn’t found, we create a new one and set some values. Otherwise we increment the impact and urgency. Finally, we add a work note to the incident.
The Active field can be configured for the Event Action record as follows:
Field | Type | Description |
---|---|---|
Active | Boolean | Enable/Disable this action. |
This flag is actually set via the Enable/Disable buttons that are available on the editable action.