Hello,
I know this is a basic question, but I am unable to find any sample code that addresses it - how should I be going about checking if a customer exists in Quantify?
We will be doing a one-way integration of Customers and Vendors into Quantify, so I need to first check if the customer exists, and if so update the existing Business Partner, and if not insert a new Business Partner. I am using C# as my language.
I was thinking of doing something like the following, but I know there is no ‘IsNull’ method in C# (that part is just pseudocode):
// Instantiate customer we are inserting/updating; check if it already exists first
if(IsNull(BusinessPartner.GetBusinessPartnerByNumber(CustomerNumber)))
{
// Create new customer
BusinessPartner customer = BusinessPartner.NewBusinessPartner(PartnerTypes.Customer);
// Set general customer fields
customer.AccountingID = CustomerNumber;
customer.Name = CustomerName;
customer.PhoneNumber = CustomerPhone;
customer.EmailAddress = CustomerEmail;
customer.FaxNumber = CustomerFax;
customer.PartnerNumber = CustomerNumber;
customer.Save();
}
else
{
// Get existing customer
BusinessPartner customer = BusinessPartner.GetBusinessPartnerByNumber(CustomerNumber);
// Set general customer fields
customer.AccountingID = CustomerNumber;
customer.Name = CustomerName;
customer.PhoneNumber = CustomerPhone;
customer.EmailAddress = CustomerEmail;
customer.FaxNumber = CustomerFax;
customer.PartnerNumber = CustomerNumber;
customer.Save();
}
Am I going about this correctly overall? Are there other methods I need to be utilizing to ensure an accurate update/insert of the customer record?
Finally, what are the required fields needed when importing/updating a customer record in this fashion? We will need to be sure to set values for each of these fields.
Please let me know if there is anything I can clarify on this.
Thanks for the assistance,
Alex