Invoicing multiple Sales order using code in AX 2012
Wondering how to post invoice for multiple Sales orders?? Below is the solution. SalesFormLetter salesFormLetter; QueryRun queryRun; Query query; str strSalesTable = "000630,000631,000643"; ; salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); query = new Query(QueryStr(SalesUpdate)); query.dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable, SalesId)).value(strSalesTable); queryRun = new QueryRun(query); salesFormLetter.chooseLinesQuery(queryRun); salesFormLetter.transDate(systemdateget()); salesFormLetter.specQty(SalesUpdate::All); salesFormLetter.printFormLetter(true); salesFormLetter.chooseLines(); salesFormLetter.run();