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

C# - Update Contact in MSCRM 2015

$
0
0

Hello,

I'm developing an integration where I read the Contacts of a view in a data source database and create these contacts in MSCRM, I can create Contacts normally.

But I have a field called CPF which is my key in both the source database and in the CRM.

Before inserting the MSCRM, I check if there is a contact with this CPF and if you need to update the CRM fields with the data from the view, but is giving the "entity id must be specified for update crm"

Can anybody help me?


if (contacts.Rows.Count> 0)
                        {
                            / * Update the contact in the CRM * /
                            conexaocrm string = "Url = http: // intranet: 5555 / Training: Username = admin, password = admin @ 15";
                            Microsoft.Xrm.Client.CrmConnection connection = Microsoft.Xrm.Client.CrmConnection.Parse (conexaocrm);

                            using (Microsoft.Xrm.Client.Services.OrganizationService orgService = new Microsoft.Xrm.Client.Services.OrganizationService (connection))
                            {
                                Entity contact = new Entity ();
                                contact.LogicalName = "contact";
                                contact [ "firstname"] = name;
                                contact [ "lastname"] = name;
                                contact [ "new_cpf"] = cpf;
                                contact [ "emailaddress1"] = email;
                                contact [ "telephone1"] = tel_comercial;
                                contact [ "birthdate"] = Convert.ToDateTime (dt_nascimento);
                                orgService.Update (contact);
                            }
                        }


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>