Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Modified event handler for a specific financial dimension

$
0
0

I have an issue where whenever the user changes the business unit financial dimension on a purchase order line, I have to pickup the address in that business unit and set it in the purchase line address.

The code to actually change the address is fine, however, the only way I found to pick up the "onModified" event for the dimension control was by doing this:

    public static void onModifyingDimensionValue(EventHandlerResult _eventHandlerResult, DimensionAttribute _dimensionAttribute, DimensionValue _origValue, DimensionValue _newValue)
    {
        //Get current record from static context
        _eventHandlerResult.booleanResult(true);
    }

    [FormEventHandler(formStr(PurchCreateOrder), FormEventType::Initialized)]
    public static void PurchTable_OnInitialized(xFormRun sender, FormEventArgs e)
    {
        //Pass form information to static context
        DimensionEntryControl c = sender.design().controlName(formControlStr(PurchLine, DimensionEntryControlLine)) as DimensionEntryControl;
        c.onModifyingDimensionValue += eventhandler(PurchCreateOrder_MyModel_Extension::onModifyingDimensionValue);
    }

However, since the onModifyingDimensionValue method is static, I have no reference to the instance of the form or its form controls.

I have tried making the method non-static without luck and also tried to implement a IDisposable context class, also with zero luck.

Does anyone know how can I achieve this?

Thank you.


Viewing all articles
Browse latest Browse all 72043

Trending Articles