Question

Let's say I want to open the vendor form in job/code. I coded a very simple select statement that I later want to use to open the vendor form for that specific vendor. How can I achieve this?

VendTable vend;
MenuFunction menuFunction;
Args args  = new Args();

select vend
    where vend.AccountNum like "*0009*";
info(vend.AccountNum); - shows an AccountNum

args.record(VendTable::find(vend.AccountNum));
menuFunction = new MenuFunction(menuitemdisplaystr(VendTable), MenuItemType::Display);
menuFunction.run(args);

The vendor form open but no data was set. Any help is appreciated.

Was it helpful?

Solution

If info(vend.AccountNum); actually outputs a valid vendor to the screen, then your code has nothing wrong with it and should work. If it does not work, I would guess you have some sort of modification or corrupt vendor data. I tested with AX 2009. I tested your code and my own version. Here is my working code I tested:

Args        args = new Args();
VendTable   vendTable;
;

select firstonly vendTable;

if (!vendTable)
    error("Missing vendor");

args.record(vendTable);

new MenuFunction(menuitemdisplaystr(VendTable), MenuItemType::Display).run(args);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top