Subscribing to onValidatingWrite


Most event handlers are straight forward. One exception is when subscribing to a table's onValidated and onValidating events.

The trick is to realize that the DataEventArgs instance passed to the event handler, is a validateEventArgs – a specialization of DataEventArgs.

Here is a template to use:

[DataEventHandler(tableStr(<TableName>), DataEventType::ValidatingWrite)]
public static void <TableName>_onValidatingWrite(Common _sender, DataEventArgs _e)
{
    boolean result = true;
    ValidateEventArgs validateEventArgs = _e as ValidateEventArgs;
    <TableName> <table> = _sender as <TableName>;
    if (<validation>)
    {
        result = checkFailed("Validation failed");
    }
    validateEventArgs.parmValidateResult(result);
}

 

The platform will keep raising the onValidating events until an event handler returns a negative result.

Here is a great post with more examples: Access stuff in the new event subscriptions

 

THIS POST IS PROVIDED AS-IS; AND CONFERS NO RIGHTS.


Comments (0)

Skip to main content