Dynamics AX 2009: Go to Main Table Form - How to select the default row?

C. Griffin picture C. Griffin · Apr 8, 2011 · Viewed 7.9k times · Source

I am overriding the jumpRef method on a drop down control in the design on my Form. Below is the code from that method. Currently, it shows the Form for the table with all rows visible. So far so good, however, I would like the specific row that had been selected on the initiating Form to be highlighted on the new Main Table Form when it displays.

public void jumpRef()
{
   ReasonTable     reasonTable;
   Args            args;
   MenuFunction    menuFunction;
   ;

   // Use whole table (i.e. No filtering, show all rows)
   reasonTable = ReasonTable;

   // Establish this form as the caller
   args = new Args();
   args.caller(element);

   // Create a new MenuFunction that launches the Reasons Menu Item
   menuFunction = new MenuFunction(
       menuitemdisplaystr(Reasons),
       MenuItemType::Display);
   menuFunction.run(args);
}

Answer

C. Griffin picture C. Griffin · Apr 8, 2011

After some more experimentation, I was able to find the answer. Adding this line solved my dilemma:

args.lookupRecord(reasonTable::find(this.text()));

It did exactly what I was hoping to accomplish. I tried this before, but couldn't figure out what object/value to put into the method.