In Dynamics AX 2012, we often need to post Sales Order using x++ code. It is very easy to post complete sales order using x++ code by utilizing the SalesFormLetter class. However, what if we need to post the sales order partially and not all the lines.
We have a chooseLinesQuery() method available in SalesFormLetter class that accepts a query object to post only the lines you want to post. See example below.
SalesTable salesTable;
SalesFormLetter salesFormLetter;
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
query = new Query(QueryStr(SalesUpdatePackingSlip));
qbds = query.dataSourceTable(tableNum(SalesLine));
// Build query range to find those lines which needs to be posted.
qbds.addRange(fieldNum(SalesLine, mzkBillingDate)).value(queryValue(systemDateGet()));
qbds.addRange(fieldNum(SalesLine, SalesStatus)).value(queryValue(SalesStatus::Backorder));
queryRun = new queryRun(query);
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.chooseLinesQuery(queryRun);
salesFormLetter.update(salesTable);
We have a chooseLinesQuery() method available in SalesFormLetter class that accepts a query object to post only the lines you want to post. See example below.
SalesTable salesTable;
SalesFormLetter salesFormLetter;
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
query = new Query(QueryStr(SalesUpdatePackingSlip));
qbds = query.dataSourceTable(tableNum(SalesLine));
// Build query range to find those lines which needs to be posted.
qbds.addRange(fieldNum(SalesLine, mzkBillingDate)).value(queryValue(systemDateGet()));
qbds.addRange(fieldNum(SalesLine, SalesStatus)).value(queryValue(SalesStatus::Backorder));
queryRun = new queryRun(query);
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.chooseLinesQuery(queryRun);
salesFormLetter.update(salesTable);
It will filter the sales line...partial also includes the quantity, how you will invoice the partial quantity of a particular line
ReplyDeleteHi asaraf,
ReplyDeleteI am not sure about it. If you have any idea about that please post below
somewhat I tried...but here I write one code..its not fully working...if you can please modify my code...
ReplyDeleteSalesFormLetter salesFormLetter;
SalesParmUpdate salesParmUpdate;
SalesParmLine salesParmLine;
;
salesParmUpdate::deleteWithoutUpdate(_salesID);
salesFormLetter = SalesFormLetter::construct( DocumentStatus::Invoice,classStr(FormletterService),identifierStr(postSalesOrderInvoice));
salesFormLetter.transDate(systemDateGet());
salesFormLetter.initParmSalesTable(SalesTable::find(_salesID));
salesFormLetter.parmSpecQtyIsSet(true);
salesFormLetter.init();
salesParmUpdate.ParmId = _salesID;
salesParmUpdate.DocumentStatus = DocumentStatus::Invoice;
salesParmUpdate.SpecQty = SalesUpdate::All;
salesParmUpdate.Storno = 1;
salesparmUpdate.insert();
salesFormLetter.salesParmUpdate(salesParmUpdate);
salesFormLetter.chooseLines(true);
ttsBegin;
select forUpdate salesParmLine order by salesParmLine.RecId desc where salesParmLine.SalesLineRecId == _salesLineRecid;
salesParmLine.DeliverNow = _qty;
salesParmLine.modifiedField(fieldNum(salesParmLine,DeliverNow));
salesParmLine.update();
ttsCommit;
try
{
salesFormLetter.run();
return true;
}
catch
{
salesParmUpdate::deleteWithoutUpdate(_salesID);
return false;
}
return false;
Hi,
ReplyDeletecould you please suggest something for PO, for invoicing selected lines.
Thanks
s7h20k6e40 z3v11w5g34 q1t40o3q63 p7p90y1b16 b0z49c4i59 u0n51f0c70
ReplyDeletehigh replica bags j54 g0v37p5i19 louis vuitton replica s20 d3u34w5z99 best replica designer bags h24 l2x81l0p74
ReplyDeleteoff white
ReplyDeletejordan 4
jordans
giannis antetokounmpo shoes
kyrie 8 shoes
golden goose sneakers
off white clothing
bape hoodie
supreme clothing
supreme