Lets have Table with string field Field. You can overwrite update() method like this:
public void update()
{
//check begin
if (this.orig().Field != this.Field)
{
info('Changed');
}
//check end
super();
}
Is it possible to create delegate which will do the check? Delegates must match method parameters exactly and there aren't any here or they can use XppPrePostArgs but I do not see a way how to get _common _ and common.orig() from it.
How to get common.orig() in delegate of the table method? Is it possible?
I am using Microsoft Dynamics AX 2012.
You can't have delegates on table methods, but you can have event handlers. See:
https://learn.microsoft.com/en-us/dynamicsax-2012/developer/event-handler-nodes-in-the-aot
http://daxtechies.blogspot.com/2013/04/how-to-use-event-handler-in-microsoft.html
You would just put a pre-event handler on the table update method, then use xppPrepostArgs
similarly to below:
public static void updatePreEventHandler(xppPrepostArgs _args)
{
CompanyInfo companyInfo = _args.getThis();
// Common common = _args.getThis(); // Alternatively
if (companyInfo.orig().Name != companyInfo.Name)
{
info('Changed');
}
}