/// <summary> /// Merge the information from two entity records of the same type. /// <para> /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.mergerequest(v=crm.8).aspx /// </para> /// </summary> /// <param name="mergeEntityType">Entity type that merged</param> /// <param name="masterRecordId">Target (merged to) of the merge operation</param> /// <param name="subordinateId">Id of the entity record from which to merge data</param> /// <param name="updatedContent">Additional entity attributes to be set during the merge operation for accounts, contacts, or leads. This property is not applied when merging incidents</param> /// <param name="performParentingChecks">Indicates whether to check if the parent information is different for the two entity records.</param> /// <returns> /// <see cref="MergeResponse"/> /// </returns> public MergeResponse Merge(MergeEntity mergeEntityType, Guid masterRecordId, Guid subordinateId, Entity updatedContent, bool performParentingChecks = false) { /* * MergeRequest CRM SDK notları * https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.mergerequest.aspx * * 2015-10-01 : Entities that support MERGE operation * - Lead * - Account * - Contact * - Incident * * Incident(Case) için kısıtlamalar * - UpdateContent property kullanılamaz. * https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.mergerequest.updatecontent.aspx * https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.mergerequest_members.aspx adresinde "MergeRequest.UpdateContent" optional görünmesine rağmen , * boş gönderilince hata veriyor. Bu nedenle "Incident" için kullanımda new Entity("incident") ataması yapıyoruz */ ExceptionThrow.IfGuidEmpty(subordinateId, "mergedRecordId"); ExceptionThrow.IfGuidEmpty(masterRecordId, "mergeToRecordId"); ExceptionThrow.IfNull(updatedContent, "updatedContent"); ExceptionThrow.IfNotExpectedValue(updatedContent.LogicalName, mergeEntityType.Description(), "UpdatedContent.LogicalName"); MergeRequest request = new MergeRequest() { Target = new EntityReference(mergeEntityType.Description(), masterRecordId), SubordinateId = subordinateId, PerformParentingChecks = performParentingChecks, UpdateContent = updatedContent }; return((MergeResponse)this.OrganizationService.Execute(request)); }