Call From By Code using X++

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


}

How is RecId field created in Dynamics AX

For more info on the recID generation, check out help contents (F1) of systemSequence class under AOT -> System Documentation -> Classes.
And the table where recIDs are stored is 'SystemSequences' stored again under System Doc -> Tables.
As to the question of when it is actually generated, my suspicion is some time during xRecord.insert() / xRecord.doinsert()