Search code examples
axaptadynamics-ax-2009microsoft-dynamicsx++ax

Dynamics AX Alert to a form that requires an active buffer


I can easily create alerts and open make it open a form with the correct record when the user clicks on "Go to Origin".

I can't do that when the form I want to open requires an active buffer though. Inside the init method it checks for the correct buffer on args().

My real question is:

How do I add the correct buffer to the form when creating an alert? Or should I add it on a MenuItem? Because as far as I know, the alert knows where to point because I provide a MenuItem for it. So when should I provide the correct buffer so the form can initialize?


Solution

  • To acomplish something like this the usual pattern is to do something like the following:

    Args args;
    MyTable myTable;
    MenuFunction menuFunction;
    
    // Find the record that needs to be passed. This could also be done through a
    // select or a call to any function returns a record of the type needed.
    myTable = MyTable::find(123);
    
    menuFunction = new MenuFunction(menuitemDisplayStr(MyMenuItem), MenuItemType::Display);
    args = new Args();
    args.record(myTable);
    menuFunction.run(args);