Skip to content

Event Listener Module

The Event Listener Module waits for specific events and initiates new workflow instances or performs actions upon event occurrence. Events are triggered at the domain level and may originate from other processes.

In addition to the common task properties, the following properties are configurable:

Event Name:
The name of the event(s) to listen for. This can be a plain text string (e.g., Customer.New) or utilize data template expressions to incorporate data model values (e.g., "PaymentComplete.{{Id}}"). Multiple event names can be specified using semicolon delimiters (e.g., "Customer.New;Customer.Update.{{Id}}").

Handle Script:
The script executed when an event is received. This script determines the workflow's subsequent actions. If left unset, the workflow engine automatically selects the first available action. The attached event data is accessible via the $Input variable as an XML instance.

If the task is configured as a starting point, a new workflow instance is initiated, and event data is mapped to matching nodes in the current workflow's data model. If the handle script does not specify an action, the workflow instance reverts. If the task is not a starting point, the workflow instance pauses until the event occurs. In this case, if the handle script doesn't define an action, the instance remains paused awaiting the next event.

Scripting Objects

This script is executed in the backend environment of the Emakin and does not have an accessible a browser DOM context and therefore navigator based JavaScript libraries such as jQuery are not available.

The following objects are available:

  • $Input Instance of the Node data that passed to the event.
  • $WorkItem Current WorkItem that is being processed.
  • $Instance Instance of the Instance current workflow instance.
  • $TestMode Indicates whether the workflow is running in test mode. In test mode, evaluates to true value.
  • $Priority Priority of the current workflow instance 0 (lowest) to 5 (highest
  • $Initiator Identifies the workflow initiator. Note that this may be null for module-type tasks.
  • $Culture Current culture of the workflow instance. Originated from the initiator's culture but can be overridden. Culture is specified in the format languagecode2-country/regioncode2. Example: (en-US or tr-TR)
  • $Templates Provides access to templates defined in the pool definition. Used for rendering the text content depending on the culture of the workflow instance.
  • $Xml Provides access to the process data model or workflow data.
  • $Case Instance of Case instance if workflow started on a case.
  • $poolVariable Custom defined pool variable by name. Variables are defined in Variables
  • $Services Allows calling SOAP services with JSON or XML content types.
  • $Decisions Allowing you to execute decision tables and models on process.
  • $scriptModule Custom defined script module. Script modules are defined in Script Modules
  • $Domain Provides access to the domain information and related methods like initiating a workflow or creating a new case.
  • $ActivityStream Allows pushing system-generated activities to the domain activity stream.
  • $Membership Provides access to users and organizational database objects.
  • $Database Allows you to perform relational database operations.
  • $Crypto Provides access to cryptographic functions such as hashing and encryption.
  • $Rest Allows interaction with REST services using JSON or XML content types.
  • $Calendar Provides access to calendar functions like adding or subtracting date in calendar rules.
  • $Files Allows access to the standard file repository for basic files.
  • $Documents Provides access to the document archive.
  • $Delegation Pprovides methods to manage delegations between users.
  • $Messages Provides functionality for sending new e-mails and parsing existing e-mail messages.
  • $XmlRepository Provides access to the non-relational XML repository database.

System Events

Emakin automatically fires the following events for integration purposes.

User Events

User.Register

Fired when a new user registers with the system. Registration occurs upon a first-time login under the current usage terms. If tenant usage terms change, re-registration with the updated terms is automatically triggered.

This event does not include input data. It expects a new workflow instance to be created and assigned to the user. If no workflow instance is created, registration completes automatically. This event is designed to comply with GDPR consent requirements.

Case Events

The following events are triggered upon completion of operations on a case instance. The $Case scripting variable automatically holds the case instance data for the triggered event.

The following Case events are available:

  • Case.Open: Fired when a case's status changes to "Open".
  • Case.Assign: Fired when a case is assigned to a user or assignment is cleared.
  • Case.Update: Fired when case properties (Subject, Description, Deadline, Profile, etc.) are updated.
  • Case.Close: Fired when a case's status changes to "Closed".
  • Case.Delete: Fired when a case is deleted from the system.
  • Case.Deadline: Fired when a case deadline is reached.
  • Case.Reply: Fired when a case receives a reply (e.g., via email or another system).

Warning

Case events are processed synchronously. Any exceptions will result in a silent rollback of the transaction.

Input Data for Case Events

Case events provide the following example XML data, accessible via the $Input variable:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<Case xmlns="http://schemas.emakin.com/case">
    <Id>43b21104-5805-40c2-b174-59c3c612977f</Id>
    <ChannelId>a272d0cf-04aa-4dd9-ba84-4c6fbe3818b8</ChannelId>
    <Number>24133</Number>
    <Subject>My Case</Subject>
    <Description>My Description</Description>
    <IsClosed>False</IsClosed>
    <DeadlineAt>2025-02-03T00:13:00</DeadlineAt>
    <Priority>Normal</Priority>
    <ContentType>Job Order</ContentType>
    <ContentTypeId>89e9d051-e04f-46fa-81dd-47c736138831</ContentTypeId>
    <CreatedAt>2022-07-22T14:05:43.7285220+03:00</CreatedAt>
    <CreatedBy Caption="John Doe" Domain="41aedbcf-01a4-4517-8a2e-4c669d432652" Type="User">467a3ace-3e67-4c44-ae75-7a48bad80490</CreatedBy>
    <UpdatedAt>2022-07-22T14:05:43.7367360+03:00</UpdatedAt>
    <UpdatedBy Caption="John Doe" Domain="41aedbcf-01a4-4517-8a2e-4c669d432652" Type="User">467a3ace-3e67-4c44-ae75-7a48bad80490</UpdatedBy>
    <AssignedTo Caption="John Doe" Domain="41aedbcf-01a4-4517-8a2e-4c669d432652" Type="User">467a3ace-3e67-4c44-ae75-7a48bad80490</AssignedTo>
    <AssignedAt>2022-07-22T14:05:43.7367360+03:00</AssignedAt>
    <ClosedAt>2022-07-22T14:05:43.7367360+03:00</ClosedAt>
    <UserTags>
        <Tag>
            <Id>a0cb3ce3-788d-4567-9e62-f24dcb5c20bd</Id>
            <Name>User Tag</Name>
        </Tag>
    </UserTags>
    <SystemTags>
        <Tag>
            <Id>80bc3bc6-8a8a-43ce-b2b4-f140c89c888c</Id>
            <Name>System Tag</Name>
        </Tag>
    </SystemTags>
    <Profile>
        <JobOrder xmlns="" State="Current">
            ...
        </JobOrder>
    </Profile>
</Case>

Remarks

If the module's script is left empty, the first available action will be automatically selected.