I am exploring the API and want to get all Business Partners but the following snippet retrieves none:
BusinessPartnerCollection partnerCollection = BusinessPartnerCollection.GetBusinessPartnerCollection(PartnerTypes.All, ActiveStatus.Both, ActiveStatus.Both);
Count() shows 0 and the print loop shows nothing. I am able to get Business Partners individually
Hi, ejjungao.
Within the GetBusinessPartnerCollection() method PartnerTypes.All is ignored for performance reasons, while PartnerTypes.Vendor, PartnerTypes.Customer, etc., may be used to retrieve the desired data.
Do let us know if you’ve any further questions.
Thank you for posting.
Thanks!
Not sure if this warrants another post but how would I go about adding multiple business partners? I see NewBusinessPartCollectionMethod(), is it the same procedure as the snippet in your Data Validation post?
Hi, ejjungao. You may use code similar to add a business partner of type Customer or Vender. This could be done iteratively to add multiple partners.
BusinessPartner customer = BusinessPartner.NewBusinessPartner(PartnerTypes.Customer);
customer.Name = <CustomerName>;
customer.EmailAddress = <Email>;
customer.PhoneNumber = <Phone>;
customer.IsActive = true;
customer.WebAddress = <WebSite>;
customer.FaxNumber = <Fax>;
if (customer.IsDirty && customer.IsSavable == false)
//Log("Customer '" + <CustomerName> + "' cannot be saved: BrokenRules:" + customer.BrokenRulesCollection.ToString());
customer.Save();
Thanks for posting.