web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / mfp's two cents / Subscribing to onValidating...

Subscribing to onValidatingWrite

Michael Fruergaard Pontoppidan Profile Picture Michael Fruergaard ... 1,616

4377.ExtensibilityLogo.png

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

*This post is locked for comments