是否可以使用“/api/data/v9.0”更新任何引用实体属性?

问题描述 投票:1回答:1

我想在Contact实体(以及其他一些实体)中更新_parentcustomerid_value但是我遇到了这样的问题 - 提供的属性是System.Object类型,当预期的类型为System.Guid时,我使用此link来更新实体属性。谁能建议我做什么?也许我做错了什么或者不可能更新ids

dynamics-crm dynamics-365 dynamics-crm-365 dynamics-crm-webapi
1个回答
1
投票

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

entity["[email protected]"] = "/contacts(DFE54660-37CD-E511-80DE-6C3BE5A831DC)" 

Reference

完整代码如下所示:

// define the data to update a record
var data =
    {
        "[email protected]": "/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

© www.soinside.com 2019 - 2024. All rights reserved.