Author Topic: Call Form By Code using X++  (Read 2691 times)

0 Members and 1 Guest are viewing this topic.

smahdy

  • Guest
Call Form By Code using X++
« on: March 24, 2014, 12:26:20 AM »
Letís call Ledger budget form from inside X++ job by pass ledgerTable record as argument and apply filter by budget model

static void CallLedgerBudgetForm(Args _args)
{
LedgerTable                            ledgerTable;
BudgetModelId                          modelId;
Args                                    args;
FormRun                                formRun;
FormDataSource                          fds;
QueryBuildDataSource                    qbds;
QueryBuildRange                        qbr;
;

select LedgerTable where LedgerTable.AccountNum == '110110' ;
ModelId= 'SUb1';

args = new Args(formstr("LedgerBudget"));
args.record(LedgerTable);
formRun = classfactory.formRunClass(args);
formRun.init();
fds = formRun.dataSource();
qbds = fds.query().dataSourceTable(tablenum(LedgerBudget));
qbr = qbds.addRange(fieldnum(LedgerBudget,ModelNum));
qbr.value(queryvalue(modelId));
qbr.status(RangeStatus::Hidden);
formRun.run();
formRun.wait();

}