General X++ Development

How do I override `validateWrite()` in a table extension?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I override validateWrite() in a table extension?

SSunny Vasty75 reputation · answered Aug 13, 2026

Use Chain of Command and preserve the standard validation result.

X++
[ExtensionOf(tableStr(MyTable))]
final class MyTable_Extension
{
    public boolean validateWrite()
    {
        boolean ret = next validateWrite();

        if (ret && !this.MyRequiredField)
        {
            ret = checkFailed('My required field must be populated.');
        }

        return ret;
    }
}

Do not throw away the result from next validateWrite(). Your validation should add to standard validation, not replace it.