首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SetParameter("fetchXml",FetchXml)不支持2016年在线客户关系管理

SetParameter("fetchXml",FetchXml)不支持2016年在线客户关系管理
EN

Stack Overflow用户
提问于 2016-06-03 19:56:07
回答 3查看 2.4K关注 0票数 1

我有这样的代码:

代码语言:javascript
复制
function FilterCasesSubgrid() {
    //var CasesSubgrid = Xrm.Page.getControl("contact").getGrid();
    var CasesSubgrid = window.parent.document.getElementById("contact");

    if(CasesSubgrid==null){ 
    setTimeout(function () { FilterCasesSubgrid(); }, 2000); //if the grid hasn’t loaded run this again when it has 
    return;
    }
    var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
    "<entity name='contact'>"+
    "<attribute name='fullname' />"+
    "<filter type='and'>"+
    "<condition attribute='fullname' operator='eq' value='s%' />"+
    "</filter>"+
    "</entity>"+
    "</fetch>";
    //Here i set the fetchxml directly to subgrid
    CasesSubgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid 
    CasesSubgrid.control.Refresh(); //refresh the sub grid using the new fetch xml 
}

错误:

TypeError:无法读取FilterCasesSubgrid处未定义的属性“SetParameter”

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-06-05 12:54:41

此代码不受支持,因此您不应该期望它能够工作。使用任何直接访问DOM (即window.parent.document.getElementById)或使用MSDN SDK中未定义的函数的函数都是不受支持的,应该避免使用。

但是,假设您只需要添加一个筛选器,就可以通过设置现有的FetchXML查询来支持这样做:

代码语言:javascript
复制
var myView = {
    entityType: 1039, // SavedQuery
    id:"{3A282DA1-5D90-E011-95AE-00155D9CFA02}", 
    name: "My Custom View"
}

//Set the view using ContactsIFollow
Xrm.Page.getControl("Contacts").getViewSelector().setCurrentView(myView);
票数 1
EN

Stack Overflow用户

发布于 2016-06-04 18:27:46

您需要等待元素控件属性(CasesSubgrid.control)。

这里已经回答了这个问题

票数 0
EN

Stack Overflow用户

发布于 2017-01-17 06:16:07

以下是解决办法:

  • 我们需要使用window.parent.document.getElementById
  • 等待控件加载到DOM中。

所以代码看起来是这样的:

代码语言:javascript
复制
function FilterCasesSubgrid() 
{
    //var CasesSubgrid = Xrm.Page.getControl("contact").getGrid();
    var CasesSubgrid =   window.parent.document.getElementById("contact");

    if(CasesSubgrid==null)
    { 
    setTimeout(function () { FilterCasesSubgrid(); }, 2000); //if the grid hasn’t loaded run this again when it has 
    return;
    }
    var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
    "<entity name='contact'>"+
    "<attribute name='fullname' />"+
    "<filter type='and'>"+
    "<condition attribute='fullname' operator='eq' value='s%' />"+
    "</filter>"+
    "</entity>"+
    "</fetch>";
    //Here i set the fetchxml directly to subgrid
  if(CasesSubgrid.control != null)
    {
    CasesSubgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid 
    CasesSubgrid.control.Refresh(); //refresh the sub grid using the new fetch xml 
      }
  else
    {
       setTimeout(CasesSubgrid, 500);
      }
}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37622413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档