Event Handlers

3 minutes to read Download PDF Edit

Event handlers define microflows that handle certain events related to the entity. Depending on the chosen moment and type, the microflow is executed before or after creating, committing, deleting or rolling back an object.

Properties

Moment

This property defines whether the microflow is executed before or after the specified event occurs.

Value Description
Before The microflow is executed before the specified event occurs.
After The microflow is executed after the specified event occurs.

Event

This property defines the event that triggers execution of the microflow.

Value Description
Create The microflow is executed when an object of this entity is created. This happens when a user clicks a Create button on a grid, or when creating an object in a microflow. In a microflow create action, an After Create is executed after the object is initialised with its default values, but before any change items specified in the action are applied.
Commit The microflow is executed when an object of this entity is committed. This happens when the user clicks a save button on a form, or when committing an object in a microflow.
Delete The microflow is executed when an object of this entity is deleted. This happens when a user clicks a delete button in a grid, or when deleting an object in a microflow.
Rollback The microflow is executed when an object of this entity is rolled back. This happens when a user clicks a cancel button in a form, or when rolling back an object in a microflow.

Microflow

This property defines the microflow that is executed for the specified event. The microflow is required to have a certain parameter and return type depending on the moment and event of the event handler:

  • Microflows of all event handlers except for ‘before create’ get the object on which the event occurs as parameter.
  • Microflows that are executed before the event should return a Boolean value that specifies whether the event should continue (True) or be cancelled (False). When multiple microflows handle the same event, it is cancelled immediately when one of the microflows returns False. In that case, some microflows might not be executed at all. Using this feature it is for example possible to cancel committing an object when a certain condition is not met.
Moment Event Gets object as parameter Returns a Boolean value
Before Create No Yes
After Create Yes No
Before Commit Yes Yes
After Commit Yes No
Before Delete Yes Yes
After Delete Yes No
Before Rollback Yes Yes
After Rollback Yes No

Raise an error when the microflow returns false (only if Moment is ‘Before’)

By enabling this option the event handler will raise an error when the microflow returns false. You can then use error handling to detect whether the event handler returned false. This makes ‘before commit’ event handlers more like native validation. If this option is disabled, a ‘before commit’ event handler can only stop the commit from happening but the rest of the microflow will still be executed.

Default value: Yes

Copyright © Mendix. All rights reserved. | Mendix.com | Terms of Use | Privacy Policy