Hi
I have modified my job as given in the thread
PurchFormLetter PurchFormLetter;
PurchTable purchaseTable;
date _ReceivedDate = systemDateGet();
PurchId _purchId = "00002545";
PurchLine purchLine;
Query query;
SysQueryRun chooseLinesQuery;
;
purchaseTable = PurchTable::find(_purchId,true);
select purchLine
where purchLine.PurchId == purchaseTable.PurchId
&& purchLine.PurchStatus != PurchStatus::Canceled;
{
purchLine.selectForUpdate(true);
purchLine.InventReceivedNow = purchLine.PurchQty;
purchLine.PurchReceivedNow = purchLine.PurchQty;
purchLine.update();
}
query = new Query(queryStr(PurchUpdate));//Query for the filter criteria
query.dataSourceTable(tableNum(PurchTable)).addRange(fieldnum(PurchTable,PurchId)).value(queryValue(purchaseTable.PurchId));
query.dataSourceTable(tableNum(PurchLine)).addRange(fieldNum(PurchLine,PurchStatus)).value(queryValue(PurchStatus::Backorder));
chooseLinesQuery = new SysQueryRun(query);
purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
ttsbegin;
purchFormLetter.chooseLinesQuery(chooseLinesQuery);
purchFormLetter.update( purchaseTable,'test',systemDateGet(),PurchUpdate::ReceiveNow,AccountOrder::None,false,false);
ttscommit;
it gives error
QueryBuildRange object not initialized.
Stack trace
(S)\Classes\PurchFormletterParmDataInvoice\adjustLinesQuery - line 85
(S)\Classes\PurchFormletterParmDataInvoice\selectChooseLines - line 26
(S)\Classes\formletterParmData\createData - line 47
(S)\Classes\PurchFormletterParmDataInvoice\createData - line 3
(S)\Classes\PurchFormletterParmDataInvoice\chooseLinesServerIL - line 32
(S)\Classes\DictClass\callStatic
(S)\Classes\SysDictClass\invokeStaticMethod - line 26
(S)\Classes\SysDictClass\invokeStaticMethodIL - line 39
(S)\Classes\Global\runClassMethodIL - line 30
(S)\Classes\PurchFormletterParmDataInvoice\chooseLinesServer - line 21
(C)\Classes\PurchFormLetter_Invoice\chooseLinesServer - line 3
(C)\Classes\PurchFormLetter\chooseLines - line 26
(C)\Classes\PurchFormLetter_Invoice\chooseLines - line 10
(C)\Classes\PurchFormLetter\update - line 46
(C)\Jobs\_partialPOInvoice - line 32
in my case all lines are packed and invoice only select line.