Home > Dynamics Ax > Dynamics Ax – AIF Web Service for AxdSalesOrder

Dynamics Ax – AIF Web Service for AxdSalesOrder


 
 

Here I am going to give the sample application for consuming the AIF web Service in C#.Net.

 

For

1)        AIF setup and Generation of the web service

2)        how to take the reference of that service in VS application.

 

go through my previuos article.

 

http://paruvella.spaces.live.com/blog/cns!F2EC589E221A4DB0!114.entry

 

Then go through the following code for consume the AIF-SalesOrder web service using C# code in VS.Net.

 

namespace SalesOrderClient

{

    class MySalesOrder

    {

        static void Main(string[] args)

        {

            CreateSalesOrder();

 

            ReadSalesOrder();

           

        }

 

        static void CreateSalesOrder()

        {

            AxdSalesOrder so = new AxdSalesOrder();

            AxdEntity_SalesTable salesTable = new AxdEntity_SalesTable();

            AxdEntity_SalesLine salesLine = new AxdEntity_SalesLine();

 

            salesTable.CustAccount = "4000";

            salesTable.CurrencyCode = "USD";

            salesTable.DeliveryDate = new DateTime(2008, 20, 7);

            salesTable.Payment = "M15";           

 

            salesLine.ItemId = "BR-14";           

            salesLine.SalesQty = 20;

            salesLine.SalesUnit = "Pcs";

 

            salesTable.SalesLine = new AxdEntity_SalesLine[] { salesLine };

            so.SalesTable = new AxdEntity_SalesTable[] { salesTable };

            so.DocPurpose = AxdEnum_XMLDocPurpose.Original;

            so.DocPurposeSpecified = true;

 

// SalesOrderServiceContractClient is the proxy generated during the

//  reference of web service

           

SalesOrderServiceContractClient soService = new SalesOrderServiceContractClient();

 

            // makes a call to Create action on the Axd

 

            EntityKey ek = soService.createSalesOrder(so);

 

            Console.WriteLine("Creates Sales Order Id : " + ek.KeyData[0].Value);

 

 

        }

 

       

        static void ReadSalesOrder()

        {

            EntityKey ek = new EntityKey();

 

            KeyField kf = new KeyField();

            kf.Field = "SalesId";

            kf.Value = "00480_036";

 

            ek.KeyData = new KeyField[] { kf };

 

            SalesOrderServiceContractClient soService = new SalesOrderServiceContractClient();

 

            // makes a call to read action on the Axd

            AxdSalesOrder so = soService.readSalesOrder(ek);

 

            // Print the sales order read

            AxdEntity_SalesTable[] salesTables = so.SalesTable;

            foreach (AxdEntity_SalesTable salesTable in salesTables)

            {

                Console.WriteLine("Sales Order details :");

                Console.WriteLine("——————–");

 

                string soName = salesTable.SalesName;                

                string custAccount = salesTable.CustAccount;

                AxdEnum_SalesStatus salesStatus = salesTable.SalesStatus.GetValueOrDefault();

 

                Console.WriteLine("Name             : " + soName);

                Console.WriteLine("Customer Account : " + custAccount);

                Console.WriteLine("Status           : " + salesStatus);

                Console.WriteLine("Purcase Order    : " + salesTable.PurchOrderFormNum);

 

 

 

                Console.WriteLine("Sales Line details :");

                Console.WriteLine("——————–");

 

                AxdEntity_SalesLine[] salesLines = salesTable.SalesLine;

                foreach (AxdEntity_SalesLine salesLine in salesLines)

                {                    

                    string itemId = salesLine.ItemId;

                    string name = salesLine.Name;

                    decimal qty = salesLine.QtyOrdered;

                    decimal lineAmt = salesLine.LineAmount;

 

                    Console.WriteLine(" (1) ");

                    Console.WriteLine("Item Id      : " + itemId);

                    Console.WriteLine("Name         : " + name);

                    Console.WriteLine("Qty          : " + qty);

                    Console.WriteLine("Line Amount  : " + lineAmt);

                }

            }

 

        }

    }

}

Advertisements
Categories: Dynamics Ax
  1. Unknown
    September 11, 2008 at 11:18 pm

    Hi,
     
    I tried using your code to create a free text invoice in AX using the freetextinvoice.create AIF web service.
    I am getting the following exception "The request failed with HTTP status 401: Unauthorized.".
    I have enable anonymous as well as integrated authentication modes in IIS.
    Any help will be appreciated.
     
    Thanks,
    Rohini

  2. Karthik
    July 5, 2011 at 2:57 pm

    Hi, This is very good post. Can you please provide how to create BOM?

  3. Mohammad Muneeb
    March 21, 2012 at 5:48 am

    Can anyone please help me out for Updating a Sales Order through AIF AX 2009. Lets say for instance i need to update the Ordered Quantity of an item for a Sales Order.

    Thanks & Regards,
    Muneeb

  4. Mohammad Muneeb
    March 22, 2012 at 5:44 am

    Hi,

    This is really a very good post.

    Can anyone please help me out with the UPDATE Process of Sales Order through AIF in AX 2009.

    For instance lets say, i want to update the ordered quantity of a particular item in a Sales Order.

    Can anyone please help me out for the same since i am struggling for the same.

    Thanks in advance 🙂

    Thanks & Regards,
    Mohhammad Muneeb

    • March 22, 2012 at 6:50 am

      Hi Mohammad,
      I have sent u mail, with the details, please let me know, if you need ay further help

      Thanks,
      Best Regards,
      Santosh Kumar Paruvella

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: