using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.NetworkInformation; using System.Data; using System.Data.OleDb; using CON_ReadCustomer.customer; namespace CON_ReadCustomer { class Program { static void Main(string[] args) { CustomerServiceClient proxy = new CustomerServiceClient(); proxy.ChannelFactory.Credentials.UserName.UserName = "user@domain"; proxy.ChannelFactory.Credentials.UserName.Password = "password"; CallContext context = new CallContext(); context.Company = "usmf"; context.LogonAsUser = @"domain\username"; AxdCustomer customer = new AxdCustomer(); AxdEntity_CustTable custTable = new AxdEntity_CustTable(); custTable.AccountNum = "123456"; 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 = "FirstName"; ////Set the name fields AxdEntity_PersonName personName = new AxdEntity_PersonName(); personName.FirstName = "FirstName "; personName.MiddleName = "MiddleName "; //personName.LastName = "LastName "; ////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 = "Street name"; address.City = "ciyt name"; address.State = "state name"; address.CountryRegionId = "country name"; address.ZipCode = "90211"; address.Roles = "Address roles"; ////Create an electronic address AxdEntity_DirPartyContactInfoView electronicAddress = new AxdEntity_DirPartyContactInfoView(); electronicAddress.LocationName = "Contact Email"; electronicAddress.Type = AxdEnum_LogisticsElectronicAddressMethodType.Email; electronicAddress.TypeSpecified = true; electronicAddress.Locator = "name@company.com"; electronicAddress.Roles = "company"; ////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 EntityKey[] key = null; key = proxy.create(context, customer); } } }
Friday, 26 December 2014
Creating Customer from AIF c# in AX 2012 R3
Subscribe to:
Post Comments (Atom)
Calculate ledger balance by dimension set in X++ in AX2012/Dynamics 365 FO
There are a variety of ways users can view balances in the general ledger. Some of the most common options are: 1. Trial balance 2. Financia...
-
static void Main ( string [ ] args ) { string customer = " US-004 " ; AxdCustomer foundCustomer = null ; C...
-
Introduction The query statement in X++ is a primary method of retrieving and manipulating data in Microsoft Dynamics AX 2012. A query can...
hi, how did you create the service you are consuming?
ReplyDeleteAbove code consumed the default CustCustomerService to create a customer from .NET
DeleteIn your example, you specify the value for custTable.AccountNum. CustTable.AccountNum is tied to a number sequence. How would you create a new instance of CustTable without passing CustTable.AccountNum so that the number sequence is utilized to generate, and return the value of AccountNum in the array "key" that was instantiated right before the proxy.create?
ReplyDeleteHi Steve,
DeleteSorry for the delayed response. Don't pass the customer account number, in case, if you're defined the number sequence for the customer account.
However, if you pass the Account number then You will be getting the below exception as
Creation has been canceled.
The number sequence "Customer number sequence number"does not allow the Customer account to be defined.
Hi Udhaya!
ReplyDeleteHow can I create the financial dimensions and set for the customer using AIF?
Thank you!