Skip to content

Event listeners

Event listeners are designed to respond to events. There are two places where event listeners can be defined: globally and in a particular document definition.

Please note that the order of events does not remain preserved. This is because events are handled asynchronously. In an asynchronous event handling system, the order in which events are received and processed by the listeners is not guaranteed to be the same as the order in which they were emitted. This is due to the nature of asynchronous operations, where different events might complete their processing at different times, depending on various factors. Therefore, administrators should not rely on the preservation of event order in such systems and should design their event handling logic accordingly.

Global event listeners

Global event listeners allow you to execute a script when an particular event occurs. To set up a global event listener, simply follow these steps:

  1. Go to the setup section and click on Event Listeners.
  2. Click on New
  3. Enter the required properties and click on Save.
Property Type Required Description
Label String Yes The label of the event listener.
Name String Yes The name of the event listener.
Event Type String Yes The type of the event to which the listener responds.
Script Reference Yes The script that is executed when an event occurs.
Active Boolean No Whether the event listener is active. Inactive event listeners do not execute a script when an event occurs.

Event listeners in document definitions

It is also possible to create an Event Action in the workflow of a document definition. Such an action is executed when an event of a particular type occurs. See the documentation on document definition workflows for more information.

Example

This example is based on the rule modeled in Emit Event action rule.

With the event type set to 'Save_check', you can add the listener as shown:

Event listener

Within the event listener, select the script you created to be called. In this example, the script Dummy Console 1 will be executed if the Save_Check event is triggered.