Common Events on Data Model
In the Eccentex Appbase/DCM ecosystem, a Common Event for Data Model is a versatile and powerful tool that empowers you to automate and enforce business logic seamlessly during the lifecycle of your entities. This mechanism allows you to orchestrate a range of actions and validations that are triggered upon the creation, updating, or deletion of an entity within the system.
At its core, Common Events provides an extensible framework that accommodates both standard and customized rules, granting you the flexibility to tailor the system's behavior according to your specific requirements.
When are Common Events Executed
A Common Event can be an ACTION or a VALIDATION. They can be fired BEFORE or AFTER the following moments in a Create/Update/Delete Entity operation:
Context | Moment |
---|---|
GENERIC_MODEL | Create Entity |
GENERIC_MODEL | Update Entity |
GENERIC_MODEL | Delete Entity |
Type of Common Events
The only action allowed to be executed is Execute Rule
Overview of Custom Rules for Common Events
The most popular use case for Common Events is to execute some sort of custom logic either to validate a user action or to do additional processing after the action has been completed.
Below is an example of how Common Events work for the Create Case process. Similar to all Common Events, the order that they get executed can be diagrammed below.
First any VALIDATION custom rules get executed. If any validation rule returns an error, the user cannot create a Case, and the user will see an error message on their screen.
Second any ACTION - BEFORE custom rules get executed. All custom rules deployed as SQL FUNCTIONs will execute synchronously. All NON-SQL FUNCTION rules, such as C# or SQL NonQuery, will be executed through the AppBase Queue asynchronously. Errors are suppressed.
Third the actual process of Case Create occurs.
Fourth any ACTION - AFTER custom rules get executed. All custom rules deployed as SQL FUNCTIONs will execute synchronously. All NON-SQL FUNCTION rules, such as C# or SQL NonQuery, will be executed asynchronously through the AppBase Queue. Errors are suppressed.
Supported custom rule types
Not all types of rules are supported for every type of Common Event. For example, a VALIDATION rule can only be an SQL FUNCTION. In contrast, an ACTION can be any AppBase rule.
An SQL FUNCTION will always execute synchronously, while all other rule types will execute through the AppBase Queue asynchronously.
Moment | SQL NonQuery Function | SQL NonQuery | C# |
---|---|---|---|
AFTER - ACTION | YES | YES | YES |
BEFORE - ACTION | YES | NO | NO |
BEFORE - VALIDATION | YES | NO | NO |
Steps
- On the top right, navigate to → <<your solution>>
- On the left, navigate to → Setup
- Navigate to Case Setup → Case Types (1)
- Select and open a Data Model using the hyperlink under the column Data Model.
- Navigate to the Common Events tab (2).
- Click the Add Common Event button (3) to add a new event.
- In the pop-up window, enter the details for the common event
- Purpose: Indicate the purpose of the event. In our example, Validate Customer Info Before Update.
- Moment: Select the Moment based on the table above. In our example, Before.
- When: Select when the event is triggered. In our example, Update Entity.
- Action or Validation: Indicate if the event is an Action or Validation. In our example, Validation.
- Event Type: Select the Execute Rule. This is the only action available for common events.
- Rule: Select the rule from the drop-down list. If needed, add the parameter(s) for the rule.
- Save the new event.
- If there is more than one event, select the order for the execution(s) using the arrows at the left of the event.