zoukankan      html  css  js  c++  java
  • Importing Customers, Vendors and Products in AX 2012

    People are starting to get into 2012 and I couldn't be happier about it!!  There is a lot of interest in services so I decided to write a couple different simple examples of how to call document services in AX.  I apologize for the formatting of code in this text editor, I promise when I wrote it, it looked like normal code :)

    This calls the vendor service:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using ConsoleApplication9.Vendors;

    namespace ConsoleApplication9

    {

        class Program

        {

            static void Main(string[] args)

            {

                VendTableServiceClient proxy = new VendTableServiceClient();

                CallContext context = new CallContext();

                context.Company = "ceu";  //New class that replaces AX endpoints.  It makes it obvious which company you are importing data into.  I love this class!!

                AxdVendTable vendor = new AxdVendTable();

                 AxdEntity_VendTable[] vendTables = new AxdEntity_VendTable[1];

                AxdEntity_VendTable vendTable = new AxdEntity_VendTable();

                //vendTable.AccountNum = "877778";  //If your number sequences for vendor accounts are set to manual set this property            vendTable.Currency = "USD";            vendTable.VendGroup = "10";

                vendTable.Name = "My Vendor Test Name";

                //Create the party record

                AxdEntity_DirPartyTable_DirPerson party = new AxdEntity_DirPartyTable_DirPerson();

                party.NameAlias = "First2";

                //Set the name fields

                AxdEntity_PersonName personName = new AxdEntity_PersonName();

                personName.FirstName = "First2";

                personName.MiddleName = "Middle2";

                personName.LastName = "Last2";

                //Add the names to the party record and set the name sequence

                party.PersonName = new AxdEntity_PersonName[1] { personName };

    party.NameSequence = "FirstLast";            vendTable.DirPartyTable = new AxdEntity_DirPartyTable_DirPartyTable[1] { party };

               

                vendTables[0] = vendTable;

                vendor.VendTable = vendTables;

                proxy.create(context, vendor);

            }

        }

    }

     

    This one is for customers:

                CustomerServiceClient proxy = new CustomerServiceClient();             CallContext context = new CallContext();             context.Company = "ceu";

                AxdCustomer customer = new AxdCustomer();

                AxdEntity_CustTable custTable = new AxdEntity_CustTable();             custTable.AccountNum = "998877";             custTable.Currency = "USD";             custTable.CustGroup = "20";             custTable.OneTimeCustomer = AxdExtType_OneTimeCustomer.Yes;             custTable.OneTimeCustomerSpecified = true;

                //Create the party record             AxdEntity_DirParty_DirPerson party = new AxdEntity_DirParty_DirPerson();             party.NameAlias = "Becky";

                //Set the name fields             AxdEntity_PersonName personName = new AxdEntity_PersonName();             personName.FirstName = "Becky";             personName.MiddleName = "ILiveForThis";             personName.LastName = "Newell";

                //Add the names to the party record and set the name sequence             party.PersonName = new AxdEntity_PersonName[1] { personName };             party.NameSequence = "FirstLast";

                //Create a postal address             AxdEntity_DirPartyPostalAddressView address = new AxdEntity_DirPartyPostalAddressView();             address.LocationName = "Location Name";             address.Street = "2122 NE 5th St";             address.City = "Beverly Hills";             address.State = "CA";             address.CountryRegionId = "USA";             address.ZipCode = "90210";             address.Roles = "Home;Delivery";

                //Create an electronic address             AxdEntity_DirPartyContactInfoView electronicAddress = new AxdEntity_DirPartyContactInfoView();             electronicAddress.LocationName = "Contact Email";             electronicAddress.Type = AxdEnum_LogisticsElectronicAddressMethodType.Email;             electronicAddress.TypeSpecified = true;             electronicAddress.Locator = "beckynewell@madeup.com";             electronicAddress.Roles = "Home";

                //Add the addresses to the party record and the party to the CustTable record             custTable.DirParty = new AxdEntity_DirParty_DirPartyTable[1] { party };             custTable.DirParty[0].DirPartyPostalAddressView = new AxdEntity_DirPartyPostalAddressView[1] { address };             custTable.DirParty[0].DirPartyContactInfoView = new AxdEntity_DirPartyContactInfoView[1] { electronicAddress };

                //Add the CustTable record to the Customer entity             customer.CustTable = new AxdEntity_CustTable[1] { custTable };

                //Create the customer             proxy.create(context, customer);

    For items you want to go out to this blog which shows you how to import items - http://blogs.msdn.com/b/dynamicsaxscm/archive/2011/07/06/product-item-data-management-services.aspx

  • 相关阅读:
    chrome 等浏览器不支持本地ajax请求的问题
    3:1 类型转换
    WebService-WSDL简单介绍
    WebService—CXF整合Spring实现接口发布和调用过程
    WebService—CXF—实现接口发布和客户端调用
    WebService—规范介绍和几种实现WebService的框架介绍
    (转)c# 扩展方法
    (转)C# Textbox的ImeMode取值对中文输入法的影响
    (转)Nandflash读写
    (转+整理)Nandflash存储
  • 原文地址:https://www.cnblogs.com/xiangliqi/p/4609645.html
Copyright © 2011-2022 走看看