Events in Acumatica
One of the key features that developers often use to improve functionality is event handling. Events allow developers to respond to changes in data, user interactions, and system processes.
Let's consider each of them:
· RowUpdating
Fires before an existing record is updated in the cache. Validate or modify the record before the update.
protected void _(Events.RowUpdating<DAC> e)
{
// Custom logic
}
· RowUpdated
Triggered after a record is updated in the cache. Useful for applying logic after the row has been changed by the user or system.
protected void _(Events.RowUpdated<DAC> e)
{
// Custom logic
}
· RowDeleting
Fired before a record is deleted from the cache. Validate or prevent deletion based on custom conditions.
protected void _(Events.RowDeleting<DAC> e)
{
// Custom logic
}
· RowDeleted
Fires after a record has been deleted from the cache.
Use case: performing actions after deletion. Use to handle any logic that needs to occur when a row is removed.
protected void _(Events.RowDeleted<DAC> e)
{
// Custom logic
}
· RowPersisting
Fires just before a record is persisted to the database. Validate data or modify record values before committing them to the database.
protected void _(Events.RowPersisting<DAC> e)
{
// Custom logic
}
· RowPersisted
Triggered after a record has been persisted to the database. Use this event for post-save operations.
protected void _(Events.RowPersisted<DAC> e)
{
// Custom logic
}
· RowInserting
Triggered just before a new record is inserted into the cache, allowing custom logic to be executed before the record is committed. Setting default values or applying validation before the record is inserted.
protected void _(Events.RowInserting<DAC> e)
{
// Custom logic
}
· RowInserted
Fires after a record has been inserted into the cache.
Initialize or validate data when a new row is added.
protected void _(Events.RowInserted<DAC> e)
{
// Custom logic
}
· RowSelecting
Fired when a record is selected from the database, just before it's returned to the UI or other consumers. Allows you to modify data as it is being loaded into the cache.
protected void _(Events.RowSelecting<DAC> e)
{
// Custom logic
}
· RowSelected
Fires when a record has been selected from the cache. Used to adjust UI behavior based on the state of the record.
protected void _(Events.RowSelected<DAC> e)
{
// Custom logic
}
· FieldDefaulting
Triggered when a field's value is about to be displayed for the first time, allowing you to set default values for fields.
protected void _(Events.FieldDefaulting<DAC, DAC.Field> e)
{
//Custom logic
}
· FieldUpdating
This event is fired when the value of a field is about to be changed but before it is committed to the cache. You can use it to intercept and alter the value being assigned to the field.
protected void _(Events.FieldDefaulting<DAC, DAC.Field> e)
{
//Custom logic
}
· FieldUpdated
This event occurs after a field's value is changed and the new value is committed to the cache. This is useful for triggering additional logic after a field has been modified.
protected void _(Events.FieldUpdated<DAC, DAC.Field> e)
{
// Custom logic
}
· FieldVerifying
This event is triggered before a field's new value is accepted. It allows you to perform validation on the value before it is saved.
protected void _(Events.FieldVerifying<DAC, DAC.Field> e)
{
// Custom logic
}
· FieldSelecting
This event is triggered when a field's value is about to be displayed on the UI, allowing you to dynamically change the displayed value.
protected void _(Events.FieldSelecting<DAC, DAC.Field> e)
{
// Custom logic
}
I would also like to add a schema that describes the sequence of events that will help prevent data overwriting.