Posting a purchase order
In Dynamics AX, a purchase order goes through a number of statuses in order to reflect its current position within the purchasing process. This status can be updated either manually by using the user interface or programmatically from code.
In this recipe, we will demonstrate how a purchase order status can be updated from code. We will confirm the purchase order created in the previous recipe and will print the relevant document on the screen.
How to do it...
1. In the AOT, create a new job named
PurchOrderPost
with the following code (replace000409
with your number):static void PurchOrderPost(Args _args) { PurchFormLetter purchFormLetter; PurchTable purchTable; purchTable = PurchTable::find('000409'); purchFormLetter = PurchFormLetter::construct( DocumentStatus::PurchaseOrder); purchFormLetter.update( purchTable, '', systemDateGet(), PurchUpdate::All, AccountOrder::None, NoYes::No, NoYes::Yes); }
2. Run the job to post the specified purchase order and display the...