Hi,
I am trying to create a customer through programmatically ( C#) using GP Web services.
I could not find Labor Rate Group, Price Matrix and Time Zone properties in Customer class.
So how can we set these fields.
I am using below code to create the customer :
CompanyKey
companyKey;
Context context;
Customer customer;
CustomerKey customerKey;
Policy customerPolicy;
Policy customerAddressPolicy;
// Create an instance of the service
using (DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(binding, endpoint))
{
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.UserName = GPUserName;
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Password = GPPassword;
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = GPDomain;
// Create a context object with which to call the web service
context =
new Context();
// Specify which company to use (sample company)
companyKey =
new CompanyKey();
companyKey.Id = (2);
// Set up the context
context.OrganizationKey = companyKey;
// Create a new vendor key
customerKey =
new CustomerKey();
customerKey.Id =
"TESTAPP00012";//"TstCustomer0001";
// Populate the vendor object
customer =
new Customer();
customer.Key = customerKey;
string accName = "TEST APP LTD";
string address_line1 = "131 Ontario";
//PriceLevelKey pkey = new PriceLevelKey();
//pkey.Id = "DEFAULT";
//customer.PriceLevelKey = pkey;
customer.Name = accName;
customer.Shortname = accName.Length > 14 ? accName.Substring(0, 15) : accName;
customer.StatementName = accName.Length > 14 ? accName.Substring(0, 15) : accName;
//if (account.Contains("telephone1") && account["telephone1"] != null)
// Get the create policy for the vendor
customerPolicy = wsDynamicsGP.GetPolicyByOperation(
"CreateCustomer", context);
// Create the vendor
wsDynamicsGP.CreateCustomer(customer, context, customerPolicy);
// Create a customer address key
CustomerAddressKey customerAddressKey = new CustomerAddressKey();
customerAddressKey.CustomerKey = customerKey;
customerAddressKey.Id = address_line1.Length > 9 ? address_line1.Substring(0, 10) : address_line1;
// Create a customer address object
CustomerAddress customerAddress = new CustomerAddress();
customerAddress.Key = customerAddressKey;
customerAddress.Name = address_line1.Length > 9 ? address_line1.Substring(0, 10) : address_line1;
// Populate properties with address information
customerAddress.Line1 = address_line1;
customerAddress.City =
"Redmond";
customerAddress.Phone1 =
new PhoneNumber();
customerAddress.Phone1.Value =
"1234567890";
// Get the create policy for the customer address
customerAddressPolicy = wsDynamicsGP.GetPolicyByOperation(
"CreateCustomerAddress", context);
// Create the customer address
wsDynamicsGP.CreateCustomerAddress(customerAddress, context, customerAddressPolicy);
}
Thanks,
Venky
*This post is locked for comments