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();
}