Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Setting Labor Rate Group, Price Matrix and Time Zone on Customer through programmatically C# - GP Web Services

Posted on by 270

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans