OnValidatedField table event handler method in Dynamics 365 F&O

Event handlers can be use to fire up your code without the necessary to customize and interfere on core logic and elements.

On the example below i’ll create an event handler that will validate FirstName value of DirPersonName table.

Open DirPersonName table and on tab Events find onValidatedField, copy and Event handler and paste in class you have created before.


class DirPersonNameTable_EventHandler
       /// <summary>
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [DataEventHandler(tableStr(DirPersonName), DataEventType::ValidatedField)]
    public static void DirPersonName_onValidatedField(Common sender, DataEventArgs e)
        DirPersonName dirPersonName = sender as DirPersonName;
        ValidateFieldEventArgs validateFieldEventArgs = e as ValidateFieldEventArgs;
        boolean ret = validateFieldEventArgs.parmValidateResult();

                case fieldNum(DirPersonName,FirstName):
            if(DirPersonName.FirstName != "MicrosoftDynamics365FO")
                        ret = checkFailed("Name must be MicrosoftDynamics365FO");



Save the class and build the project.


2 thoughts on “OnValidatedField table event handler method in Dynamics 365 F&O

  1. Hmm it appears like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything. Do you have any tips and hints for first-time blog writers? I’d certainly appreciate it.


  2. I do enjoy the way you have framed this situation and it does provide me some fodder for consideration. However, through what precisely I have experienced, I basically hope when other responses stack on that folks remain on issue and not start upon a tirade involving some other news of the day. Yet, thank you for this fantastic piece and although I do not agree with it in totality, I respect the standpoint.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s