如何打开包含所选记录的表单?

Tas*_*sto 2 ax x++ axapta

假设我想在作业/代码中打开供应商表单。我编写了一个非常简单的选择语句,稍后我想用它来打开该特定供应商的供应商表单。我怎样才能实现这个目标?

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);
Run Code Online (Sandbox Code Playgroud)

供应商表单已打开,但未设置数据。任何帮助表示赞赏。

Ale*_*tny 5

如果info(vend.AccountNum);实际上在屏幕上输出了一个有效的供应商,那么您的代码没有任何问题并且应该可以工作。如果它不起作用,我猜你有某种修改或损坏的供应商数据。我用 AX 2009 进行了测试。我测试了您的代码和我自己的版本。这是我测试过的工作代码:

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);
Run Code Online (Sandbox Code Playgroud)