I am attempting to merge contact records in CRM. The following is my code and works fine until the end line at var merged = (MergeResponse)service.Execute(merge); I have tracers in the original code and is definitely erroring out at that specific line.
// Create the target for the request.
var target = new EntityReference();
// Id is the GUID of the account that is being merged into.
// LogicalName is the type of the entity being merged to, as a string
var targetId = (Guid)master.Attributes["contactid"];
target.LogicalName = entity.LogicalName;
// Create the request.
var merge = new MergeRequest();
// SubordinateId is the GUID of the account merging.
merge.SubordinateId = (Guid)subordinates.Attributes["contactid"];
merge.Target = target;
merge.PerformParentingChecks = false;
tracer.Trace("\nMerging contact2 into contact1 and adding " + "\"test job title from plugin\" as job title");
// Create another contact to hold new data to merge into the entity.
// If you use the subordinate account object, its data will be merged.
var updateContent = new Entity();
updateContent.LogicalName = entity.LogicalName;
updateContent["jobtitle"] = "test job title from plugin";
// Set the content you want updated on the merged account
merge.UpdateContent = updateContent;
// Execute the request.
var merged = (MergeResponse)service.Execute(merge);
The following is the error:
Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault] Message: An error occurred in TransformaniaMergeContactsPlugin.Detail: 421301f5-3f26-4eb9-a546-88a93ff52f33 -2147220891 d2p1:keyOperationStatus</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:int">0</d2p1:value> d2p1:keySubErrorCode</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:int">-2146233088</d2p1:value> d2p1:keyPlugin.ExceptionFromPluginExecute</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">Transormania.Plugins.TransformaniaMergeContactsPlugin</d2p1:value> d2p1:keyPlugin.ExceptionRetriable</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:boolean">false</d2p1:value> d2p1:keyPlugin.ExceptionSource</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">PluginExecution</d2p1:value> d2p1:keyPlugin.OriginalException</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">PluginExecution</d2p1:value> d2p1:keyPlugin.PluginTrace</d2p1:key> <d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">Hello plugin In Master entity for each results Master: test | contact | 2325a10e-527e-e911-a81d-000d3a1d9cdc | Group ID: 00000001 Subordinate: Test | User | b01d0639-847d-e911-a81a-000d3a1f0599 | Group ID: 00000001 Master Guid: 2325a10e-527e-e911-a81d-000d3a1d9cdc Entity Logical Name: contact Subordinate Id: b01d0639-847d-e911-a81a-000d3a1f0599
Merging contact2 into contact1 and adding "test job title from plugin" as job title Before update content Merge Content: Microsoft.Xrm.Sdk.Entity</d2p1:value> An error occurred in TransformaniaMergeContactsPlugin. 2021-12-09T18:49:10.8671998Z false PluginExecution PluginExecution Hello plugin In Master entity for each results Master: test | contact | 2325a10e-527e-e911-a81d-000d3a1d9cdc | Group ID: 00000001 Subordinate: Test | User | b01d0639-847d-e911-a81a-000d3a1f0599 | Group ID: 00000001 Master Guid: 2325a10e-527e-e911-a81d-000d3a1d9cdc Entity Logical Name: contact Subordinate Id: b01d0639-847d-e911-a81a-000d3a1f0599
Merging contact2 into contact1 and adding "test job title from plugin" as job title Before update content Merge Content: Microsoft.Xrm.Sdk.Entity
I'm not seeing anything specific to what the error is and am running out of options. Any extra eyes will help.


Report
All responses (
Answers (