dynamics-crm - 如何使用 JavaScript 将自定义 FetchXML 应用于子网格

标签 dynamics-crm crm microsoft-dynamics dynamics-crm-online dynamics-crm-365

将自定义 FetchXML 应用于子网格的实现似乎已从 CRM 2011/13 更改为 Dynamics 365。更改是关于 GridControl.SetParameter()

我关注过许多讨论同一问题的文章,但目前在 Dynamics 365 Online 上没有任何效果。 有没有其他方法可以实现相同的功能?

在我下面的代码中,我试图获取与帐户相关的所有电话和电子邮件事件,并将它们显示在帐户表单上的子网格上。

//Shows only the PhoneCall activities related to Organisation
//var allPhoneCallsGrid = window.parent.document.getElementById("AllPhoneCalls"); //Not supported by Microsoft
//var allPhoneCallsGrid = document.getElementById("AllPhoneCalls"); //Not Supported by Microsoft

var allPhoneCallsGrid = Xrm.Page.getControl("AllPhoneCallactivities"); //Sub-grid is on the Account Form

if (allPhoneCallsGrid == null) {
  setTimeout(function() {
    AccountForm.AccountFormOnLoad();
  }, 2000); //if the grid hasn’t loaded run this again when it has
  return;
}

var accountId = Xrm.Page.data.entity.getId();
var allPhoneCallsfetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
  "  <entity name='activitypointer'>" +
  " <attribute name='activitytypecode' />" +
  "        <attribute name='subject' />" +
  "        <attribute name='ownerid' />" +
  "        <attribute name='prioritycode' />" +
  "        <attribute name='regardingobjectid' />" +
  "        <attribute name='activityid' />" +
  "        <attribute name='scheduledstart' />" +
  "        <attribute name='scheduledend' />" +
  "        <attribute name='statecode' />            " +
  "        <attribute name='community' />   " +
  "    <order attribute='modifiedon' descending='false' />" +
  "    <filter type='and'>" +
  "      <condition attribute='activitytypecode' operator='ne' value='4206' />" +
  "      <condition attribute='activitytypecode' operator='eq' value='4210' />" +
  "    </filter>" +
  "    <link-entity name='incident' from='incidentid' to='regardingobjectid' alias='ad'>" +
  "      <filter type='and'>" +
  "        <condition attribute='account' operator='eq' uitype='account' value='" + accountId + "' />" +
  "      </filter>" +
  "    </link-entity>" +
  "  </entity>" +
  "</fetch>";

allPhoneCallsGrid.control.SetParameter("fetchXml", allPhoneCallsfetchXml); //Unable to get property 'SetParameter' of undefined or null reference
//allPhoneCallsGrid.getGrid().setParameter("fetchXml", allPhoneCallsfetchXml);
allPhoneCallsGrid.control.Refresh(); //refresh the sub grid using the new fetch xml

最佳答案

使用 Xrm 页面对象,我们可以将 JavaScript 绑定(bind)到子网格的 onload 事件。

可以使用 Ribbon Workbench 工具将 JavaScript 绑定(bind)到子网格。

关于如何在子网格事件上编写 JavaScript 的示例代码,请引用此链接 http://www.inogic.com/blog/2015/11/identify-the-trigger-for-an-on-load-event-for-sub-grid-in-dynamics-crm/

关于dynamics-crm - 如何使用 JavaScript 将自定义 FetchXML 应用于子网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44024756/

相关文章:

dynamics-crm-2011 - 如何使用JavaScript将base64文件保存到客户端?

dynamics-crm-2011 - 将实体 ID 解析为 MS Dynamics CRM 中的实体类型

version-control - 使用 Siebel CRM 的推荐开发实践?

import - Dynamics CRM 2011 的计划导出/导入

javascript - 在 CRM 4.0 的实体 View 中添加外部链接

dynamics-crm - Dynamics CRM 营销列表动态日期条件

sql - 如何在 vtiger 上修改管理员密码?

php - 更新 VTiger 中的现有工单

crm - Dynamics 365 - IOrganizationService/Web Api

php - 在 PHP 中验证 Microsoft Dynamics