WINDOWS Live Search

To contact me for any clarifications regarding any posts / information, please mail me at arijit [dot] basu [at] gmail [dot] com

Thursday, November 23, 2006

How to post SO's or PO's with X++

If you need to update a sales order or a purchase order without any user dialogs, Axapta provides you with a simple interface to do just that.The SalesFormLetter and PurchFormLetter classes contain the update method, which gives you an easy interface to setup and run posting of a sales order or a purchase order.

static void postSalesFormLetter(Args _args)
SalesFormLetter salesFormLetter;
salesTable salesTable;


while select salesTable
where salesTable.DocumentStatus == DocumentStatus::Invoice &&
salesTable.SalesId == 'SO/07/123' // Select the SO Number
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); // Get a new instance of SalesFormletter
salesFormLetter.transDate(SystemDateGet()); // Set the invoicedate
salesFormLetter.update(salesTable, // SalesTable
SalesUpdate::All, // Quantity to update (SpecQty)
AccountOrder::None, // AccountOrder
false, // Proforma only?
true); // Printout?


Anonymous said...

Thank you wery mutch


Venkatesh said...


Very useful post.But for one change,

salesTable.DocumentStatus == DocumentStatus::Invoice has to be

salesTable.DocumentStatus < (or !=) DocumentStatus::Invoice


Anonymous said...


I was searching for something similar, thanks a lot for posting this, you really made my day. :)


PepeSifuentes said...

Do you have the code to unpost a po?
I have been playing with the same class to try to reverse the posting by updating the recieved now qty and calling the same update method but I dont get the desire results, any help will be very much appreciated.

Pooja said...

Hi !!
thanks a lot Mr Basu.. ur blogs have been very usefull always....
I have a small doubt while doing the same PO invoice the purchFormLetter.update(), asks for a 'num'. Can u pla tel me... what is this num??
Thanking you in advance.

Debashree Dutta

Pooja said...

Thanks for the detailed prpgram, ur blogs hav always been very useful.
Can u plz tell me while doing the same for PO, the purchFormLetter.update() method asks for a 'num' type argument. Can u pla tell me what is this??

Thanking u in advance.