tdg*_*gdr 2 merge sdk microsoft-dynamics records crm
我一直在尝试使用Dynamics CRM 2011 SDK中的Merge示例. http://msdn.microsoft.com/en-us/library/hh547408.aspx
我修改了一下.我创建了两个Contacts而不是Accounts(尽管代码中的某些变量名称可能会另有说明.例如,_account1Id实际上是contact1的GUID.)
第一个联系人记录包含姓名,姓氏和电话字段.第二个联系人记录填写了姓名,姓氏和电子邮件字段.
合并发生的部分如下.可以从顶部的链接看到原始代码.
当我运行以下修改的示例时,电子邮件地址不会合并到新的联系人记录中.我得到的是一个合并的联系人与其中一个记录的值,添加了地址数据,但没有电子邮件.我认为这应该用第二条记录中的非空字段填充主记录的空字段.
作为Dynamics CRM的新手,我经过大量的谷歌搜索和调试后无法理解原因.如果有人可以就问题可能给我一些反馈,我会很高兴的.
提前致谢.
_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));
}
Run Code Online (Sandbox Code Playgroud)
这种行为将如预期的那样 - 合并将从子级到主服务器移动子记录(因此可能是机会,地址等),但不会尝试锻炼您想要复制的字段.推理(我猜)是潜在的商业逻辑含义是无穷无尽的 - 你想复制电子邮件吗?如果所有电子邮件字段都填写怎么办 自定义字段怎么样?还有很多其他案例,我相信大家都能想到.
编辑:
要解决此问题,请在MergeRequest类上调用一个属性UpdateContent.如果更新此属性上的字段,则值将合并到父记录中.
您可以在发布的链接中看到这个:
// Create another account to hold new data to merge into the entity.
// If you use the subordinate account object, its data will be merged.
Account updateContent = new Account();
updateContent.Address1_Line1 = "test";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6711 次 |
| 最近记录: |