简体   繁体   English

设置子网格的fetchXML时,无法读取Dynamics CRM中未定义的属性“ SetParameter”

[英]Cannot read property 'SetParameter' of undefined in Dynamics CRM while setting up fetchXML of a subgrid

I've following code snippet to set up the fetchxml of a subgrid on invoice form but it throws the exception: Cannot read property 'SetParameter' of undefined . 我按照以下代码片段在发票表单上设置了子网格的fetchxml,但它引发了异常: 无法读取undefined的属性'SetParameter'

Any Idea how it could be resolved. 任何想法如何解决。

Code Snippet: 代码段:

function filterUsers() {
    try {
        debugger;
        var orderId = Xrm.Page.getAttribute("salesorderid").getValue()[0].id;
        var spGrid = getSubgrid("new_salesperson");
        //var spGrid = Xrm.Page.getControl("new_salesperson");
        if (spGrid == null || spGrid == 'undefined') {
            setTimeout(filterUsers, 500);
            return;
        }
        else {
            var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
                    "  <entity name='systemuser'>" +
                    "    <attribute name='fullname' />" +
                    "    <attribute name='title' />" +
                    "    <attribute name='address1_telephone1' />" +
                    "    <attribute name='systemuserid' />" +
                    "    <order attribute='fullname' descending='false' />" +
                    "    <link-entity name='new_salesorder_systemuser' from='systemuserid' to='systemuserid' visible='false' intersect='true'>" +
                    "      <link-entity name='salesorder' from='salesorderid' to='salesorderid' alias='ab'>" +
                    "        <filter type='and'>" +
                    "          <condition attribute='salesorder' operator='eq' value='" + orderId + "' />" +
                    "        </filter>" +
                    "      </link-entity>" +
                    "    </link-entity>" +
                    "  </entity>" +
                    "</fetch>";
            spGrid.control.SetParameter("fetchXml", fetchXml);
            spGrid.control.SetParameter("effectiveFetchXml", fetchXml);
            spGrid.control.SetParameter("fetchXmlForFilters", fetchXml);
            spGrid.control.refresh();
        }
    }
    catch (e) {
        if (e.message == "Cannot read property '0' of null" || e.message == "orders[0] is undefined" || e.message == "Unable to get property '0' of undefined or null reference")
            return;
        alert("Error: " + e.message);
    }

}

function getSubgrid(elementName) {
    debugger;
    if (document.getElementById(elementName) == null || document.getElementById(elementName) == 'undefined') {
        return window.parent.document.getElementById(elementName);
    }
    else {
        return document.getElementById(elementName);
    }
}

Manipulating the DOM directly in CRM is not supported. 不支持在CRM中直接操作DOM。 Find another way. 寻找另一种方式。

It appears to me that you are trying to add a subgrid of users to the invoice form. 在我看来,您正在尝试将用户的子网格添加到发票表单。 The users have been associated with sales orders with your custom relation, new_salesorder_systemuser . 用户已通过您的自定义关系new_salesorder_systemuser与销售订单相关联。

I would suggest simply creating a quick view form on sales order with the subgrid of users and selecting Only Related Records . 我建议您简单地使用用户的子网格在销售订单上创建快速查看表单,然后选择“ 仅相关记录” You can then add this quick view form to your invoice form. 然后,您可以将此快速查看表单添加到发票表单。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dynamics CRM2016:无法读取未定义的属性“ SetParameter” - Dynamics CRM2016: cannot read property 'SetParameter' of undefined 动态CRM。 在subgrid中完全自定义FetchXml - Dynamics CRM. Fully custom FetchXml in subgrid Dynamics CRM 2015 Online:SubGrid 的 control.SetParameter 方法不可用 - Dynamics CRM 2015 Online: SubGrid's control.SetParameter method is not available FetchXML查询在子网格中返回的Dynamics CRM 2015中的活动记录-主题超链接打开新的活动 - Activity records in Dynamics CRM 2015 returned in subgrid by FetchXML query - Subject hyperlink opens new Activity 设置变体选项数组时出错无法读取未定义的属性“0” - error while setting variants option array Cannot read property '0' of undefined dynamics crm在关联的视图上获取子网格的名称 - dynamics crm get name of subgrid on associated view 如何以Dynamics CRM形式调整子网格的高度? - How to resize the height of the subgrid in dynamics crm forms? TypeError:在设置 MetaMask 以显示 NFT 时无法读取未定义的属性(读取“地图”) - TypeError: Cannot read properties of undefined (reading 'map') while setting up MetaMask to display NFT 在 Dynamics 365 CRM 统一界面中重新加载/刷新子网格时重新加载表单 - Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface 根据条件禁用 Dynamics CRM 可编辑子网格中的列 - Disable column in Dynamics CRM editable subgrid based on a condition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM