Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Microsoft Dynamics AX 2009 : Processing Business Tasks - Posting sales orders

1/30/2012 5:29:11 PM
Sales order posting is also done in a very similar way to posting a purchase order. The posting function can be executed from code and can be integrated into various customizations.

In this recipe, we will use a standard Dynamics AX API to post and print a sales packing slip document from code. As an example, we will post and print a packing slip for the sales order created in the previous recipe.

How to do it...

  1. 1. In AOT, create a new class called SalesOrderPost with the following code (replace SO-100160 with your number):

    class SalesOrderPost

    {
    }
    public static void main(Args _args)

    {
    SalesFormLetter salesFormLetter;
    salesTable salesTable;
    ;
    salesTable = SalesTable::find('SO-100160');
    salesFormLetter = SalesFormLetter::construct(
    DocumentStatus::PackingSlip);
    salesFormLetter.update(
    salesTable,
    systemdateget(),
    SalesUpdate::All,
    AccountOrder::None,
    NoYes::No,
    NoYes::Yes);
    }

  2. 2. Run the class to create a packing slip for the specified sales order and display the Packing slip document on the screen:

  1. 3. Open Accounts receivable | Sales Order Details, select the previously specified sales order, the click Inquiries button, and choose Packing slip to view results:

How it works...

First, we create a new class named SalesOrderPost with a main() method.

The method starts with finding sales order SO-100160, which we created in the previous recipe. Here, we would normally replace this code with user input or an output from another source.

Next, we call construct() on the SalesFormLetter class to create a new salesFormLetter instance. The method accepts an argument of type DocumentStatus, which defines the type of posting. Here, we use DocumentStatus::PackingSlip for sales packing slip posting. construct() also accepts a second optional boolean argument, which controls whether a new SalesParmUpdate record, used for sales order posting grouping, should be created. The default is true.

And finally, we call update() on salesFormLetter, which does actual posting. It accepts a number of arguments:

  • The sales order header record, i.e. SalesTable.

  • The transaction date. The default is system date.

  • The quantity to be posted. The default is SalesUpdate::All.

  • This argument is not used. The default is AccountOrder::None.

  • A boolean value defining should preview or actual posting be done.

  • A boolean value defining should document be printed.

  • A boolean value specifying should printing management be used. The default is false.

  • Keep the remaining quantity on order; otherwise it is set to zero. This argument is used when posting credit notes.

  • A container of a number of TmpFrmVirtual records. This argument is optional and is used only when posting sales invoices.

There's more...

SalesFormLetter could also do other types of posting, like order confirmation, picking list, or invoice. For example, to invoice for the sales order, replace the code:

salesFormLetter = SalesFormLetter::construct(
DocumentStatus::PackingSlip);

with:

salesFormLetter = SalesFormLetter::construct(
DocumentStatus::Invoice);

Run the class and notice that now the sales order was invoiced:

Open Accounts receivable | Sales Order Details, select the previously specified sales order, click the Inquiries button, and choose Invoice to view the results:

Other -----------------
- Active Directory Domain Services 2008 : Add a Computer to a Group
- Active Directory Domain Services 2008 : Move a Computer Object
- Windows Server 2008 Server Core : Starting and Configuring the Registry Editor (part 2)
- Windows Server 2008 Server Core : Starting and Configuring the Registry Editor (part 1)
- Microsoft BizTalk 2010 : Consuming ASDK-based Adapters - Installation
- Microsoft BizTalk 2010 : Understanding the ASDK-based adapter
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 4)
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 3) - Modify the New Workflows & eService Configuration
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 2)
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 1) - Configuring ASP.NET Membership
 
 
Top 10 video Game
-   Why We're Excited For the FFVII Remake
-   Mortal Kombat X | Predator Brutality
-   Mortal Kombat X | Predator Fatality
-   Poly Bridge [PC] Early Access Trailer
-   Silence: The Whispered World 2 [PS4/XOne/PC] Cinematic Trailer
-   Devilian [PC] Debut Trailer
-   BlazBlue Chrono Phantasma EXTEND | Launch Trailer
-   Allison Road | Prototype Gameplay
-   Clash of Clans | 'Dark Spell Factory' Update
-   Shoppe Keep [PC] Debut Trailer
-   Orcs Must Die! Unchained [PC] What's New in Endless Summer v2.3 Patch
-   Gunpowder [PC] Launch Trailer
-   Uncharted 4: A Thief's End | E3 2015 Extended Gameplay Trailer
-   V.Next [PC] Kickstarter Trailer
-   Renowned Explorers [PC] Launch Date Trailer
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
 
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
programming4us programming4us
PS4 game trailer XBox One game trailer
WiiU game trailer 3ds game trailer
Trailer game
 
programming4us
Heroes Charge
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Game Trailer