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 - Creating sales orders

1/1/2012 6:13:35 PM
Creating sales orders in Dynamics AX is very similar to creating purchase orders both in the application and from code.

In this recipe, we will create a new sales order from code. We will use a similar approach to that which we used in the Creating purchase orders recipe.

How to do it...

  1. 1. Open AOT and create a new class called SalesOrderCreate with the following code:

    class SalesOrderCreate

    {
    }
    public static void main(Args _args)

    {
    NumberSeq numberSeq;
    SalesTable salesTable;
    SalesLine salesLine;
    ;
    ttsbegin;
    numberSeq = NumberSeq::newGetNumFromCode(
    SalesParameters::numRefSalesId().numberSequence,
    true);
    salesTable.SalesId = numberSeq.num();
    salesTable.initValue();
    salesTable.CustAccount = '1101';
    salesTable.initFromCustTable();
    if (!salesTable.validateWrite())
    {
    throw Exception::Error;
    }
    salesTable.insert();
    salesLine.SalesId = salesTable.SalesId;
    salesLine.ItemId = '1205';
    salesLine.createLine(true, true, true, true, true, true);
    ttscommit;
    }



  2. 2. Run the class to create a new sales order.

  3. 3. Open Accounts receivable | Sales Order Details to view the newly created sales order:

How it works...

First we create a new class, which will run our code using its main(). Here, we place all the code into a ttsbegin/ttscommit pair to make sure everything is rolled back if something goes wrong.

The method starts with generating the next number for a new sales order.

Next, we call initValue() and initFromCustTable() to initialize various purchTable fields. Note that initFromCustTable() works slightly different from, i.e. we set CustAccount first and call the method afterwards instead of passing CustTable as an argument. Normally, the customer account should come from a user selection screen or some other source. For demonstration purposes, we simply use customer 1101 from the list. initFromVendTable()

Once validation is completed successfully by using validateWrite(), we create a sales order header record by calling salseTable.insert().

Next, we create sales order lines. First, we assign the sales order number and then we specify the item number. As before, the item number should come from user input or some other source. For demonstration purposes, we use item 1205 from the inventory list.

And finally, we call createLine() on the salesLine table to create a line. This method could be called a number of times depending on how many lines need to be created. The method accepts a number of optional boolean arguments:

  • Perform data validations before saving? The default is false.

  • Initialize from SalesTable table? The default is false.

  • Initialize from InventTable table? The default is false.

  • Calculate inventory quantity? The default is false.

  • Add miscellaneous charges? The default is true.

  • Use trade agreements to calculate item price? The default is false.

  • Reserve the item? The default is false.

  • Ignore customer credit limit? The default is false.

  • An inventory transaction number used to copy product model information. This argument is used only when the Product Builder module is active. The default is empty.

Other -----------------
- Microsoft Dynamics AX 2009 : Processing Business Tasks - Creating purchase orders
- Active Directory Domain Services 2008 : Delete a Computer Object
- Active Directory Domain Services 2008 : Create a Computer Object
- Windows Server 2008 Server Core : Managing the System Time with the W32Tm Utility
- Microsoft Dynamics CRM 4.0 Accelerators : Analytics Accelerator (part 2) - Analytics Accelerator Installation
- Microsoft Dynamics CRM 4.0 Accelerators : Analytics Accelerator (part 1)
- Microsoft Dynamic CRM 4.0 : Google Maps Integration
- Microsoft Systems Management Server 2003 : Disaster Recovery - Backing Up the Site Through Systems Management Server
- Microsoft Systems Management Server 2003 : Disaster Recovery - Backup Process Flow
- InfoPath with Sharepoint 2010 : Create a Master or Detail Display Form for SharePoint Lists
 
 
Top 10 video Game
-   Super Smash Bros: Ryu tritt dem Kampf bei (Wii U)
-   Splatoon ~ First U.S. Splatfest announcement
-   Broken Sword 5 | PS4 and Xbox One Announcement Trailer
-   Earthbound Beginnings (Wii U)
-   Counter-Strike: Source - E3 2004-Trailer
-   Half-Life 2 - E3 2003 Gameplay-Trailer
-   Half-Life 2 - E3 2003 Tech-Demo
-   DOOM 4 | Single Player Gameplay from Bethesda Press Conference
-   Dishonored 2 | Announcement trailer from Bethesda Press Conference
-   The Elder Scrolls Legends | Debut Trailer from Bethesda Press Conference
-   Fallout 4 Gameplay Clip
-   Earthbound Beginnings | Debut Trailer for Virtual Console
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
Women
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone