AX – D365FO – Add methods to tables through extension – X++

You first create a new class in the extension model. This class will augment the InventTable table, and enable access to the table’s fields and methods in a manner that is easy to read and understand. It’s important that you choose the correct name for your augmentation class. This name must be unique across all types in all models that are deployed.

final class InventTableMy_Extension
    public void myDefaultInventLocationId()
        // This would have partner specific logic to initialize the new field.
        this.MyInventLocationId = this.inventLocationId();

You can now add new methods to the augmentation class. These methods will then appear in IntelliSense for variables of the InventTable type, just as if they were defined directly on the table. This behavior applies to both static methods and instance methods.

There are a few rules for augmentation classes:

  • They must be final.
  • They must be suffixed by _Extension.
  • They must be decorated with the [ExtensionOf()] attribute.

Now you can use your new method, for example, from an event handler:

class InventTableMy_EventHandler
    [DataEventHandler(tableStr(InventTable), DataEventType::Inserting)]
    public static void InventTable_onInserting(Common sender, DataEventArgs e)
        InventTable inventTable = sender as InventTable;
        // Call the method as if it was defined directly on InventTable.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di

Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...