ESM Listener Lifecycle
Overview
A listener lifecycle has three or four phases, depending on whether it’s a pre save or a post save listener:
- Data card save: The listener is triggered during the save of a data card.
- Checking source conditions: Source conditions are checked.
- Checking target conditions (post-save listeners only): The group of target data cards is defined based on target conditions. This phase only happens if the listener is a post save listener.
-
Executing actions: One or more actions are executed to the target data card.
- In pre save listener’s case, the target data card is the so called “source" data card, which “hosts” the listener.

Data Card Save
The listener is triggered during the save of a data card.

Triggering Listeners

Execution Order of Handlers and Listeners

Listeners, Handlers and Visual Workflow Automation
- Workflow actions is not executed as the last pre-save listener. It starts from the first workflow node (or last processed node) and in a single execution processes multiple nodes until it arrives at a node (such as a Timer or Approval) that will not allow it to go further.
- Visual Workflow Automation __initialization__ happens in the end of the pre-save part of save cycle.
- Visual Workflow Automation __Processing__ happens in the end of the post-save part of save cycle.
Checking Source Conditions
Each listener has source conditions, which describe when the listener should react to the event. For example, the condition might be as follows:
(attribute "state" old value != attribute "state" new value) && (attribute "state" new value == "closed")Conditions can be much more complicated with "and" and "or" operators and even nested ones. If the source data card matches the conditions, the execution moves forward.

Pre-Save Listener

Post-Save Listener

AND Example

OR Example

Combined SC

Implemented Source Conditions
| Name | Description |
|---|---|
| CombinedSourceCondition | Combines conditions (which also can be CombinedSourceConditions) with AND or OR operators. In the XML the outermost source_conditions element itself is an CombinedSourceCondition. |
| AlwaysTrueSourceCondition | Always true, i.e. the data card is always matched with this condition. |
| EntitySourceCondition |
|
| FolderSourceCondition | Is the data card in a specific folder on in some other (operator !=). |
| GuiEditSourceCondition | True when the source data card is edited from the ESM UI. |
| NewDataCardSourceCondition | Are we about to save a new data card: yes or no |
| PropertySourceCondition | Compare some field in the data card (attribute) before saving or after saving (current_value true or false) to another field value before saving or after saving with some operator. Supported operators depend on the datatype. |
| ValueSourceCondition | Compare some field (attribute) before saving or after saving (current_value true or false) to some constant value with some operator. Supported operators depend on the datatype, e.g. you can't compare a reference to constant (like data card's id or name). |
| ReferencePathValueSourceCondition | Compare some value found in a reference path ($code1:code2:code3$) before saving or after saving (current_value true or false) to some constant value with some operator. Supported operators depend on the datatype. |
| ReferencePathPropertySourceCondition |
With this source condition it is possible to compare to values of two such attributes which one or both can be reference. The first of these may be a reference to local (non-reference) attribute, but the other must be some referenced data card's attribute. Both attributes must have the same datatype.
Multivalue attributes and matching of the condition:
|
See more examples of source conditions in SourceConditionExamples.xml:

Checking Target Conditions
Target conditions are similar to search conditions in the ESM UI. The actions of the listener are performed on the data cards which match the conditions. Note that the source data card should be excluded using these conditions.
An example of an target condition could be the following:
(template == "ticket") && (reference attribute "caused by" target == source data card) && (attribute "state" value == "open")



Note:
If, during the execution of a listener, a possible infinite loop is detected → the listener execution ends and an error is displayed.
For example, if listener A modifies data card B, it triggers listener B and listener B modifies data card A.
Implemented Target Conditions
| Name | Description |
|---|---|
| CombinedTargetCondition | Combines multiple conditions (which can also be CombinedTargetConditions themselves) to one with operators AND or OR. |
|
ValueTargetCondition
|
Compares an attribute value from data card to some constant with some operator. Supported operators depend on the data type, for example references can't be compared to data card name or id. An exception to this is a reference to source or reference from source (configured with attribute code). |
| PropertyTargetCondition | Compares data card's attribute's value to some other attribute's value with some operator. Supported operators depend on the data types used. |
| SourcePropertyTargetCondition | Compares target data card's attribute's value to an attribute's value on the source data card with some operator. Supported operators depend on the data types used. |
| EntityTargetCondition |
|
| SpecialTargetCondition |
This condition can be used to define/check the following properties:
|
See examples of target conditions in TargetConditionExamples.xml:

Executing Actions
One or more actions are executed to the target data card. In pre save listener’s case, the target data card is the so called “source" data card, which “hosts” the listener.

Implemented Actions
| Name | Pre save | Post Save | Description |
|---|---|---|---|
| AlwaysFailDataCard (Action) | Yes | No | Prevents saving the data card. |
| ChangeDataCardValues | Yes | Yes | Sets a value to a field. |
| CopyDataCardValues | Yes | Yes | Copies a value from source data card to another attribute's value or to a value of an attribute in the target data card. Can also copy values behind references. If multivalue, existing values will be REPLACED. Multivalues work only on host data card, not behind references. |
| CopySourceReference | Yes | No | Creates a reference from target data cards to source data card. |
| CreateDataCard | No | Yes | Creates a new Data card, based on configured template and in configured folder. Optionally adds references between the creator and the created data cards, and sets any attribute values in the created card. As a special case, can add the time when editing in the Efecte GUI was started |
| EntityDataCard | Yes | No | Moves a data card to trashcan, restores it from the trashcan, permanently deletes, hides or makes a data card visible. |
| Expression(Action) | Yes | Yes | Will execute a defined Python script on target data cards. |
| FolderDataCard | Yes | Yes | Moves a data card to a specific folder. |
| SaveDataCard | No | Yes | Saves the data card. This enables calculating new values to attributes containing a handler (ExpressionHandler or such). |
| SaveDataCardXmlToFile | No | Yes | Saves the data card in XML form to a specified file and folder. Note that this action operates only on the source data card that is saved. If the file exists, it will be overwritten (file is deleted before writing new file). Action tries first to write the XML to a temporary file and then renames the temporary file to the specified file. This is to prevent anyone reading the result file before it's completely written. |
| SendDataCardXmlToWebService | No | Yes | NOTE: No “Action” in the name. Sends data card in XML form to configured SOAP web service. Note that this action operates only on the source data card that is saved. |
| SendMailAction | No | Yes | Sends mail. |
| SendSourceChangedJMSMessage(Action) | Yes | Yes | Action will send a JMS message to queue when the data card is saved. The contents of the message is the data card in whole in Efecte XML format. |
| TargetedSccmUpdate | No | Yes | Triggers a targeted SCCM update. Only used together with SccmIntegrationTask. |
| TransformDataCard | No | Yes | Action transforms currently edited data card to another data card. Uses transform rules and target folder defined in transforms in template editor. |
| SendDataCardXmlToHttpAction | No | Yes | Sends data card in XML form to a chosen web service. Note that this action operates only on the source data card that is saved. |
See examples of target conditions in TargetConditionExamples.xml:

Table of Contents