AX2012 / D365FnO – HOW TO WRITE VALIDATEDWRITE EVENTHANDLER AT TABLE LEVEL USING X++

D365fno-PostImage

In this blog, I will try to explain how to write code for validate write for a table-level event handler using X++ in D365FnO.

To begin, create a new class and name it “VendGroup_Table_EventHandler”. Then, copy the code provided below into the newly created class.

class VendGroup_Table_EventHandler
{
    [DataEventHandler(tableStr(VendGroup), DataEventType::ValidatedWrite)]
    public static void VendGroup_onValidatedWrite(Common sender, DataEventArgs e)
    {
        VendGroup vendGroup = sender as VendGroup;
        ValidateEventArgs validateEventArgs = e as ValidateEventArgs;
        boolean ret = validateEventArgs.parmValidateResult();

        if(ret)
        {
            if(vendGroup.GroupRegion == "")
            {
                ret = checkFailed("Vendor region must be filled.");
                validateEventArgs.parmValidateResult(ret);
            }  
        }
    }
}

See the following error screenshot:

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.