28 May’15

Dynamics AXCreating Sales Order with address in AX 2012 R2 via AIF through .Net

Creating Sales Order with address information in AX 2012R2CU7 via AIF through .Net Code

Please see the below .net code

static void Main(string[] args)
            // Instantiate an instance of the service client class.
            SalesOrderServiceClient proxy = new SalesOrderServiceClient();
            // Create an instance of the document class.
            AxdSalesOrder salesOrder = new AxdSalesOrder();
            // Create instances of the entities that are used in the service and
            // set the needed fields on those entities.
            AxdEntity_SalesTable salesTable = new AxdEntity_SalesTable();
            salesTable.CurrencyCode = "USD";
            salesTable.CustAccount = "C846456";
            salesTable.ReceiptDateRequested = Convert.ToDateTime("4/21/2015");
            salesTable.Payment = "PP";
            AxdEntityKey_LogisticsPostalAddress LPA = new AxdEntityKey_LogisticsPostalAddress();
            LPA.Location_LocationId = "5637282089";
            AxdExtType_EffectiveDateTime date = new AxdExtType_EffectiveDateTime();
            date.timezone = AxdEnum_Timezone.GMT_COORDINATEDUNIVERSALTIME;
            DateTime dateValue = new DateTime(2015, 4, 29, 14, 10, 53, 001, DateTimeKind.Utc);
            date.timezoneSpecified = false;
            date.localDateTimeSpecified = false;
            date.Value = dateValue; 
            LPA.ValidFrom = date; 
            salesTable.DeliveryPostalAddress = LPA;
            AxdEntity_SalesLine salesLine = new AxdEntity_SalesLine();
            salesLine.ItemId = "10-009";
            salesLine.SalesQty = 9;
            salesLine.SalesUnit = "ea";
            CallContext callContext = new CallContext();
            callContext.Language = "en-us";
            callContext.Company = "KTEC";
            salesTable.SalesLine = new AxdEntity_SalesLine[1] { salesLine };
            salesOrder.SalesTable = new AxdEntity_SalesTable[1] { salesTable };
                // Call the create method on the service passing in the document.
                EntityKey[] returnedSalesOrderEntityKey = proxy.create(callContext,salesOrder);
                // The create method returns an EntityKey which contains the ID of the sales order.
                EntityKey returnedSalesOrder = (EntityKey)returnedSalesOrderEntityKey.GetValue(0);
                Console.WriteLine("The sales order created has a Sales ID of " + returnedSalesOrder.KeyData[0].Value);
            catch (Exception e)

Error Details in AX exceptionlog :

“The value in field DeliveryPostalAddress is invalid.”

Written by

Team Member


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Reading more then 10K records in D3FOE OData API

    11 July’ 2018

    Introduction: We all know Dynamics 365 Finance and Operations has limitation of 10K records to be fetched at a time usi...

    Read more
  • Paging in D365 Customer Engagement v9.0

    10 July’ 2018

    Introduction: The Xrm.retrieveMultipleRecords method is used to retrieve a collection of records in Dynamics 365 Custom...

    Read more
  • Set up Dynamics 365 connection in Microsoft Social Engagement

    10 July’ 2018

    Introduction: This blog explains how to Set up Dynamics 365 connection in Microsoft Social Engagement. Steps to be follo...

    Read more
  • Voice of the Customer failed to install

    10 July’ 2018

    Introduction: Many people face issues in installing Voice of Customer solution on v9 environment and trying repeatedly ...

    Read more
  • Scribe Insight AX as a Web Service Find Block issue

    10 July’ 2018

    Introduction: If we need to look up for any value from AX then we do it by using a Find Block in Scribe Insight Eg: Basi...

    Read more