Search code examples
axaptax++dynamics-ax-2012

How to get common.orig() in delegate of the table method?


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.


Solution

  • You can't have delegates on table methods, but you can have event handlers. See:

    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');
        }
    }
    

    enter image description here