0

I want to post the invoice of selected lines of purch order(PO) through code. need help in the code. can anyone help me with coding ?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50

1 Answers1

0

The FormLetter framework has the method chooseLinesQuery which accepts a query of lines to update.

See this blog.

Code for sales order (you can more or less substitute 'sales' with 'purch'):

SalesTable salesTable = SalesTable::find('your-order');
SalesFormLetter salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
Query query = new Query(QueryStr(SalesUpdatePackingSlip));
QueryBuildDataSource qbds = query.dataSourceTable(tableNum(SalesLine));
// Build query range to find those lines which needs to be posted.
qbds.addRange(fieldNum(SalesLine, SalesStatus)).value(queryValue(SalesStatus::Backorder));
salesFormLetter.chooseLinesQuery(new queryRun(query));
salesFormLetter.update(salesTable);
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50