Partial posting of invoice for sales order

Hi All,

I’m facing a rare issue while posting invoice. We have a screen where we can post packing slip and invoice at a time for single/multiple sales orders. The issue is when a certain sales order is invoiced, partial invoice is posted for the sales order (only the last sales line is not invoiced). The issue occurs only for following sales order.

Sales order has 9 lines and last sales line qty is more than 2.

From a custom screen, packing slip is posted first and invoice is posted through the following code.

queryPack = new Query(QueryStr(SalesUpdatePackingSlip));

qbdsPackSalesTable = queryPack.dataSourceTable(tableNum(SalesTable));

qbdsPackSalesTable.addRange(fieldnum(SalesTable, SalesId)).value(“SOR0136098”);

queryRun = new queryRun(queryPack);

salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);









from salesFormLetter.chooseLines() method, it goes to child class method i.e., salesFormLetter_Invoice.chooseLines() and then the control goes to ‘chooseLinesFromPackingslip’ method of ‘salesFormLetter_Invoice’ class.

The issue what I found exists in following code (while(


chooseLines.reset(); // if the select button is used from saleseditlines

while (


if (chooseLines.changed(tablenum(SalesTable)))


localSalesTable = chooseLines.get(tablenum(SalesTable));

mayJournalBePosted = this.mayJournalBePosted(localSalesTable);


if (! mayJournalBePosted)




if (chooseLines.changed(tablenum(SalesLine)))


localSalesLine = chooseLines.get(tablenum(SalesLine));





When method executes for second quantity of last sales line, local variable ‘localSalesLine’ is nullified.

what could be the possible reason for this behavior ?



Hi Raghav,

Have you identified the solution of above problem.

I am also having the same problem. I have created one sales order with two sales line. I have generated packing slip for first line and now i want to generate invoice for that first line only i.e. partial invoice of sales order through code.

Do u have created any job or code for this. If you are having then please share with me. Or else you can guide me through this that i can achieve this task.

Thanks in advance.

Vijay Solanki.

Hi Vijay,

you can directly create invoice for single line if the packing slip is created for it by using below code

salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesTable = SalesTable::Find(“SO-001”);
SalesFormLetter.update(SalesTable,systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, false, false);