Posting a sales order
In Dynamics AX, a sales order goes through a number of statuses in order to reflect its current position within the sales process. The status can be updated either manually using the user interface or programmatically from code.
In this recipe, we will demonstrate how a sales order status can be updated from code. We will register a packing slip for the sales 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
SalesOrderPost
with the following code (replaceSO-101248
with your number):static void SalesOrderPost(Args _args) { SalesFormLetter salesFormLetter; salesTable salesTable; salesTable = SalesTable::find('SO-101248'); salesFormLetter = SalesFormLetter::construct( DocumentStatus::PackingSlip); salesFormLetter.update( salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, NoYes::No, NoYes::Yes); }
2. Run the job to post the specified sales order, and display the...