I am using the BaseEntityEventListener.OnSaving method where in addition to saving the entity I want to call an asynchronous method. Is there any way I can convert OnSaving to asynchronous?
I am trying to validate a record before it gets inserted into the DB using entity events layer : public override void OnInserting(object sender, EntityBeforeEventArgs e);
If the validation fails, I would like to display a message to the user. Is there a built in method like set validation message or something? I understand this can be done through Web socket but I would prefer if I am able to use a built in validator.
You can simply throw an exception from the event and it will halt the insert process and display the exception message to the user.
An an example, this OnInserting event checks to ensure the Also known as field is not empty:
using System;using Terrasoft.Core.Entities;using Terrasoft.Core.Entities.Events;namespace FX.EntityEventListeners{[EntityEventListener(SchemaName ="Account")]publicclass UsrAccountEntityEvents : BaseEntityEventListener
{publicoverridevoid OnInserting(object sender, EntityBeforeEventArgs e){
base.OnInserting(sender, e);
var account =(Entity)sender;if(string.IsNullOrEmpty(account.GetTypedColumnValue<string>("AlternativeName"))){thrownew Exception("Also known as cannot be blank");}}}}
This displays this message when the user inserts an account without this field populated:
You can simply throw an exception from the event and it will halt the insert process and display the exception message to the user.
An an example, this OnInserting event checks to ensure the Also known as field is not empty:
using System;using Terrasoft.Core.Entities;using Terrasoft.Core.Entities.Events;namespace FX.EntityEventListeners{[EntityEventListener(SchemaName ="Account")]publicclass UsrAccountEntityEvents : BaseEntityEventListener
{publicoverridevoid OnInserting(object sender, EntityBeforeEventArgs e){
base.OnInserting(sender, e);
var account =(Entity)sender;if(string.IsNullOrEmpty(account.GetTypedColumnValue<string>("AlternativeName"))){thrownew Exception("Also known as cannot be blank");}}}}
This displays this message when the user inserts an account without this field populated:
Lets say, I have a Business process which is triggered when an Email Template record is modified, and that Email template is updated via a Package installation, the logical expectation is that the 'Modified' event is triggered and the Business process runs. We however notice that the event is not triggered, and the business process does not run.
Do Package installations and changes through that trigger entity events? Do Package installations effect object changes to the DB via the ORM or does that mechanism work differently?
If I wrote a business process which had a trigger to the SysPackage object and looked for modifications to a specific package, will it get triggered when I install that package??
Our application doesn't support designing business processes that are triggered after modifying system objects. The core of business process mechanisms works on low-level API which doesn't support start signals functionality. This is done in order to avoid any kind of accidents with business process mechanisms and also for performance maintaining reasons.
I am not sure I understood this - "The core of business process mechanisms works on low-level API which doesn't support start signals functionality". Are you saying that the start signal functionality does not work in Business processes?
The Entity event layer is a powerful tool to listen to changes to schemas on the server side and perform actions based on them. The documentation states the following -
The Entity event layer mechanism is triggered after executing the event subprocesses of an object.
Few questions below -
Are entity events triggered for all system schemas & custom schemas? We know it works with Custom schemas, but we have had a few instances where it did not get triggered for system schemas Eg 'System administration object' or 'Image' object. We also notice that a business process with Start signal tied to the "System administration object" or 'Image" object also doesn't work.
Are there any restrictions around which schemas/objects or kinds of changes, these entity events will get triggered for?
Are the entity layer events triggered on the server exactly the same as the 'Signal' start events that we configure in the Business process designer?
1. It is triggered for all entity objects present in the configuration section.
2. It gets triggered by any CRUD operations performed using DataServevice (Entity and EntitySchemaQuery), OData, and OOTB business process elements. It will not get triggered if data is changed using Insert, Update, Delete classes, and if data is changed directly on the DB level.
1. It is triggered for all entity objects present in the configuration section.
2. It gets triggered by any CRUD operations performed using DataServevice (Entity and EntitySchemaQuery), OData, and OOTB business process elements. It will not get triggered if data is changed using Insert, Update, Delete classes, and if data is changed directly on the DB level.
I am presuming that there are no special settings to be done to enabled for them to be triggered on System objects. Hence, our errors are not the expected behavior is what I understand.
1. Do entity events get triggered for virtual objects & views as well? Virtual objects are also objects displayed in Configuration. So going by your explanation, It should. Can you confirm?
2. Are entity events listenable on the Client side? I do not think so. Can you confirm?