I've been trying to get the Merge example in Dynamics CRM 2011 SDK to work. http://msdn.microsoft.com/en-us/library/hh547408.aspx
I've modified it a bit. I've created two Contacts instead of Accounts (although some variable names in the code might suggest otherwise. For example _account1Id is in fact a GUID for contact1.)
The first Contact record has name, surname and telephone fields filled. The second Contact record has name, surname and email fields filled.
The part where merge occurs is below. The original code can bee seen from the link at the top.
When I run the example with following modifications, the e-mail address doesn't get merged into the new contact record. What I get is one merged Contact with the values from one of the records, with address data added, but no e-mail. I thought this was supposed to fill empty fields of the primary record with the non-empty fields from the second record.
Being very new to Ms Dynamics CRM, I couldn't understand the reason after much googling and debugging. I'll be glad if someone can give me some feedback about what the problem might be.
Thanks in advance.
_serviceProxy.EnableProxyTypes();
CreateRequiredRecords(); // created two contacts with same name, surname. first record has telephone1 filled, second record has emailaddress filled.
EntityReference target = new EntityReference();
target.Id = _account1Id;
target.LogicalName = Contact.EntityLogicalName;
MergeRequest merge = new MergeRequest();
merge.SubordinateId = _account2Id;
merge.Target = target;
merge.PerformParentingChecks = false;
Contact updateContent = new Contact();
updateContent.Address1_Line1 = "test";
merge.UpdateContent = updateContent;
MergeResponse merged = (MergeResponse)_serviceProxy.Execute(merge);
Contact mergeeAccount =
(Contact)_serviceProxy.Retrieve(Contact.EntityLogicalName,
_account2Id, new ColumnSet(allColumns: true));
if (mergeeAccount.Merged == true)
{
Contact mergedAccount =
(Contact)_serviceProxy.Retrieve(Contact.EntityLogicalName,
_account1Id, new ColumnSet(allColumns: true));
}