I worked a few AX upgrade projects. Unfortunately multi-layer architect is so painful with upgrade projects. Seem this problem is solved with extensions approach.
When you wanted to add fields/indexes/relations... in tables/data entities or controls in forms you create extensions directly:
Enums doesn't use numbers (at least in development environment) anymore. This's very good for upgrade projects. Unfortunately I lived problems about added elements without any gap to system enums. How it was a problem:
Sample, a system enum goes 1-2-3-4-5 and a developer added a new element. He/she actually should add new element as at least from 20 maybe 30 but added from 6. And in new version Microsoft added 6. :)
In the case of writing code there are some shortcuts. You can open related object and click right mouse for copy template:
A sample class method extension:
[PostHandlerFor(classStr(LedgerJournalCheckPost), methodStr(LedgerJournalCheckPost, run))]
public static void LedgerJournalCheckPost_Post_run(XppPrePostArgs args)
LedgerJournalCheckPost post = args.getThis() as LedgerJournalCheckPost;
journalTable = post.parmLedgerJournalTable();
You can put this method in any class and this method will run after run method. If we selected Pre-event, it would be run before run.
In this case we extend ondeleted of a table:
public static void LedgerJournalTable_onDeleted(Common sender, DataEventArgs e)
LedgerJournalTable ledgerJournalTable = sender as LedgerJournalTable;
If we want to add a new method of a table, things change a bit.
We need a new class named Table name and _Extension word like this:
final class AGC_ABCRCreditTable_Extension
public void updateDefaultDimension()
this.DefaultDimension = 11111;
public static void ABCRCreditTable_onModifiedField(Common sender, DataEventArgs e)
ABCRCreditTable creditTable = sender as ABCRCreditTable;
ModifyFieldEventArgs eventArgs = e;
int id = eventArgs.parmFieldId();
if (ABCRParameters::find().CRCreditAccountType == ABCRAccountType::Vend)
Override form lookup method:
[FormDataSourceEventHandler(formDataSourceStr(ABCRCreditTable, ABCRCreditTable), FormDataSourceEventType::Initialized)]
public static void ABCRCreditTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
var overrides = new AGC_CreditTableExt();
sender.object(fieldNum(ABCRCreditTable, TradeNumber)).registerOverrideMethod(methodStr(FormDataObject, lookup),
methodStr(AGC_CreditTableExt, lookupTrade), overrides);
With this sample we make run code at up in forms data source OnInitialized event. We override datasource tradenumber fields lookUp method with AGC_CreditTableExt class lookupTrade method. You can write this code in any class. I choosed AGC_CreditTableExt .
Recently I learned another extension method for override lookups by Peter Ramer's blog by CancelSuperCall() .