You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Xrm Web Api更新Dynamics 365自定义查找字段遇错求助

解决Dynamics 365 Web API更新单值查找字段的资源找不到错误

核心问题定位

你遇到的ODataUnrecognizedPathException错误,本质是odata.bind路径中使用了目标实体的单数逻辑名称,而非Web API要求的复数实体集名称。Dynamics 365 Web API的实体访问路径必须使用实体的复数形式(由系统自动生成或自定义设置),单数名称会被识别为无效路径。

解决方案步骤

  1. 获取目标实体的复数逻辑名称
    访问你的CRM环境的元数据端点:[CRM环境URL]/api/data/v9.2/$metadata,搜索目标实体的单数逻辑名称(new_personnelstatus_custom),找到对应的<EntitySet>节点,比如:

    <EntitySet Name="new_personnelstatus_customs" EntityType="Microsoft.Dynamics.CRM.new_personnelstatus_custom" />
    

    这里的Name属性值(new_personnelstatus_customs)就是需要用到的复数名称。

  2. 修正Web API代码
    将odata.bind路径中的单数实体名称替换为复数名称,同时保留之前确认正确的导航属性名称(new_PersonnelStatus_Custom):

    Xrm.WebApi.updateRecord("new_nursesdatabase", "aa09e593-a624-ed11-b83e-000d3a371e11", {
        "new_PersonnelStatus_Custom@odata.bind": "/new_personnelstatus_customs(5052e892-5aee-ec11-bb3d-000d3a5a2232)"
    }).then(function success(result) {
        console.log(result);
    }, function(error) {
        console.error(error.message); // 增加错误捕获便于排查
    });
    
  3. 额外排查点

    • 验证目标实体路径正确性:直接在浏览器中访问[CRM环境URL]/api/data/v9.2/new_personnelstatus_customs(5052e892-5aee-ec11-bb3d-000d3a5a2232),如果能返回目标记录的JSON数据,说明路径完全正确。
    • 检查权限:确保当前操作的用户拥有new_nursesdatabase记录的更新权限,以及目标new_personnelstatus_custom记录的读取权限,权限不足也可能触发资源找不到的报错。

内容的提问来源于stack exchange,提问作者Trevyn Case

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 03:25:37