Purchase order posting is the next logical step after creating a purchase order. Normally, in the application, users use the Posting button on the Purchase Order Details form to post purchase orders. This function can also be executed from code and can be integrated into various customizations.
In this recipe, we will use a standard Dynamics AX API to post a purchase order and print the relevant document from code. As an example we will post and print the previously created purchase order.
In AOT, create a new class called PurchaseOrderPost with the following code (replace 000097 with your number):
class PurchaseOrderPost { } public static void main(Args _args) { PurchFormLetter purchFormLetter; PurchTable purchTable; ; purchTable = PurchTable::find('000097'); purchFormLetter = PurchFormLetter::construct( DocumentStatus::PurchaseOrder); purchFormLetter.update( purchTable, ...