I am new to CRM development, and I am hoping to get help. I am using the early bound service context generated by CRMSvcUtil and Linq to write queries and update records.
I am doing this in a Batch service job and not a plugin, I need find a way to update only the fields/attributes that changes and not all the fields on the service.Udpate method. How can I do this, please see my code below. I basically get a list of details from a service and then update Dynamics, this job runs daily to check if data is new if its new it should update just that field and not everything. Please see code below.
//Loop through each client and search for record in OCM service foreach (var a in DESCClient) { string dt_desccdoe = a.dt_DESCCode; string phoenixClientName = a.Name; var phoenixConfig = ConfigManager.GetPhoenixConfig(serviceContext); var ocmConfig = ConfigManager.GetOcmConfig(serviceContext); using (var ocmManager = new Integration.Ocm.OcmManager(new Phoenix.Core.Factories.SqlConnectionFactory(phoenixConfig.StagingDbConnectionString), ocmConfig)) { Log.InfoFormat("Desc Code is " dt_desccdoe); ocmClientSearch = ocmManager.SearchOcmClients(phoenixClientName, numberofPages, defaultPageNum); if (ocmClientSearch.OcmClient.Count > 0) { //Get the Desc Code using the OCM search endpoint as the CRM desc codes fail on some records. var ocmDescCode = ocmClientSearch.entity1[0].DGMFID; ocmDetails = ocmManager.GetOcmClientDetail(0, ocmDescCode); if (ocmDetails != null) { //Update the Client entity with the OCM Desc details serviceContext.Update(new Account { AccountId = a.AccountId, dt_Designation = ocmDetails.IndependenceInformation?.FirstOrDefault().Designation, dt_DesignationDescription = ocmDetails.IndependenceInformation?.FirstOrDefault().DesignationDescription, dt_DesignationRuleSet = ocmDetails.IndependenceInformation?.FirstOrDefault().DesignationRuleSet, dt_DesignationType = ocmDetails.IndependenceInformation?.FirstOrDefault().DesignationType, }); } } }