General X++ Development

Can I add instance variables to a table extension class?

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

Can I add instance variables to a table extension class?

SSunny Vasty75 reputation · answered Aug 13, 2026

Yes. A table augmentation class can add runtime state to the effective table buffer.

X++
[ExtensionOf(tableStr(MyTable))]
final class MyTable_XppForge_Extension
{
    private int xppForgeRuntimeCounter;

    public void xppForgeIncrementCounter()
    {
        xppForgeRuntimeCounter++;
    }
}

The important part: this is runtime state on that table buffer instance. It is not a database field and it is not persisted with the record.

If the value belongs to the record, add a real table field. If it is only temporary state needed while that buffer is alive, extension state can be useful. Just remember that a different/recreated buffer is a different instance, so do not treat the variable like persisted table data.