Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Duplicate Contact? (C#/SDK question)

$
0
0

I want to accomplish this feat in programming in C# for CRM.

  1. Check if the contact exists, if it does not, then create the contact. 
  2. The conflict I'm facing is if the contact exists, only the last name is a required field which makes checking the data challenging and there may be more than 1 contact that might be erroneously entered.

Here's my code, I can only figure out how to create a GUID using the last name but Not on more than one field. Can someone shed some light on this and provide your thoughts from those who has more experience in this field?

How can I check on more than just the last name? Perhaps 'lastname' , 'firstname' , and 'Company'?

Thanks in advance!

string firstName= "John";
string lastName = "Doe";

 var ContactValue = GetEntityCollection(_service, "contact", "lastname", lastName, new ColumnSet("contactid", "lastname")); //does it return anything
                                Guid contactpersonid = (Guid)ContactValue[0].Id;
                                salesorder["neu_orderedbyid"] = new EntityReference("contact", new Guid(contactpersonid.ToString()));

Viewing all articles
Browse latest Browse all 79901

Trending Articles