无法在Retrieve的列集中指定子属性(Cannot specify child attributes in the columnset for Retrieve)

编程入门 行业动态 更新时间:2024-10-10 07:28:27
无法在Retrieve的列集中指定子属性(Cannot specify child attributes in the columnset for Retrieve)

在尝试合并Microsoft CRM中的联系人时,我使用以下代码 -

//c1ID and c2ID are GUIDs of duplicated contacts.

EntityReference target = new EntityReference();
target.LogicalName = Contact.EntityLogicalName;

target.Id = c2ID;

MergeRequest merge = new MergeRequest();
// SubordinateId is the GUID of the account merging.

merge.SubordinateId = c1ID;
merge.Target = target;
merge.PerformParentingChecks = true;

Contact updater = new Contact();
Contact updater2 = new Contact();

updater = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c1ID)).First();
updater2 = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c2ID)).First();

MergeResponse mergedR = (MergeResponse)xrmSvc.Execute(merge);
 

当我在这里尝试我的执行调用时,我收到此错误 -

无法在Retrieve的列集中指定子属性。 属性:owneridname。

我没有正确设置吗?

In attempting to merge contacts in Microsoft CRM, I am using the following code -

//c1ID and c2ID are GUIDs of duplicated contacts.

EntityReference target = new EntityReference();
target.LogicalName = Contact.EntityLogicalName;

target.Id = c2ID;

MergeRequest merge = new MergeRequest();
// SubordinateId is the GUID of the account merging.

merge.SubordinateId = c1ID;
merge.Target = target;
merge.PerformParentingChecks = true;

Contact updater = new Contact();
Contact updater2 = new Contact();

updater = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c1ID)).First();
updater2 = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c2ID)).First();

MergeResponse mergedR = (MergeResponse)xrmSvc.Execute(merge);
 

When I try my Execute call here,I get this error -

Cannot specify child attributes in the columnset for Retrieve. Attribute: owneridname.

Am I not setting something correctly?

最满意答案

我希望我有一些这方面的文档,但是虽然官方文档指出UpdateContent是可选的,但经验证明它实际上是必要的。 在我测试过的MergeRequest ,我总是在请求中包含该属性,并且在动态3.0 的MSDN论坛中有一篇帖子提出了同样的建议。

事实上,当我尝试在没有分配UpdateContent 情况下合并我的组织中的两个联系人时,我实际上得到一个FaultException说明如下:

缺少必填字段“UpdateContent”

即使文档说它是可选的!

所以我建议使用下面的内容填充UpdateContent属性,看看是否有效:

var merge = new MergeRequest
{
    // SubordinateId is the GUID of the account merging.

    SubordinateId = c1ID,
    Target = target,
    PerformParentingChecks = true,
    UpdateContent = new Contact()
};

I wish I had some documentation for this, but although the official documentation notes that the UpdateContent is optional, experience proves that it is in fact necessary. In the MergeRequests I've tested, I always include that property in the request, and there's a post in the MSDN forums for Dynamics 3.0 that suggests the same.

In fact, when I try to merge two contacts in my org without UpdateContent assigned, I actually get a FaultException saying the following:

Required field 'UpdateContent' is missing

Even though the documentation says it's optional!

So I'd suggest populating the UpdateContent property with something as in the below and see if that works:

var merge = new MergeRequest
{
    // SubordinateId is the GUID of the account merging.

    SubordinateId = c1ID,
    Target = target,
    PerformParentingChecks = true,
    UpdateContent = new Contact()
};

                    
                     
          

更多推荐

本文发布于:2023-08-04 17:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1419189.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   Retrieve   child   columnset   attributes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!