【问题标题】:Can any referencing entity attribute be updated using "/api/data/v9.0"?是否可以使用“/api/data/v9.0”更新任何引用实体属性?
【发布时间】:2019-03-11 14:09:19
【问题描述】:

我想更新联系人实体(和其他一些)中的_parentcustomerid_value,但我遇到了这样一个问题 - 提供的属性是 System.Object 类型,而预期是 System.Object 类型。指导 我用这个link 来更新实体属性。谁能建议我该怎么做?也许我做错了什么或者无法更新ids

【问题讨论】:

    标签: dynamics-crm dynamics-365 dynamics-crm-365 dynamics-crm-webapi


    【解决方案1】:

    对于查找属性,您必须使用single valued navigation property 而不是lookup property

    entity["parentcustomerid_contact@odata.bind"] = "/contacts(DFE54660-37CD-E511-80DE-6C3BE5A831DC)" 
    

    Reference

    完整的代码如下所示:

    // define the data to update a record
    var data =
        {
            "parentcustomerid_contact@odata.bind": "/contacts(DFE54660-37CD-E511-80DE-6C3BE5A831DC)"
        }
    // update the record
    Xrm.WebApi.updateRecord("contact", "61a0e5b9-88df-e311-b8e5-6c3be5a8b200", data).then(
        function success(result) {
            console.log("Contact updated");
            // perform operations on record update
        },
        function (error) {
            console.log(error.message);
            // handle error conditions
        }
    );
    

    Read more

    【讨论】:

    • 很多,但问题是我想更新现有实体(使用 PATH 请求 PATCH [Organization URI]/api/data/v9.0/contacts(00000000-0000-0000- 0000-000000000001)) 具有新的属性值 parentcustomerid 。那么如何实现呢?
    • @PavloMykhailyshyn 同样的事情应该可以工作。 docs.microsoft.com/en-us/dynamics365/customer-engagement/…
    • parentcustomerid_contact@odata.bind 区分大小写,如果您使用全部小写,则会失败。甚至生成调用的工具也有错误(昨天在创建请求中发现)
    • @Draiden 这是真的,因为它需要模式名称..而不是逻辑名称..stackoverflow.com/questions/36700796/…。大多数情况下,OOB 在两个名称中都很小。自定义属性会有所不同..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-23
    • 2021-11-12
    • 1970-01-01
    • 2011-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多