SetParameter(“ fetchXml”,FetchXml)在CRM 2016在线中不支持 [英] SetParameter("fetchXml", FetchXml) doesn't support in crm 2016 online
问题描述
我有以下代码:
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
}
ERROR刷新子网格:
ERROR :
TypeError:无法读取
FilterCasesSubgrid中未定义的属性'SetParameter'
TypeError: Cannot read property 'SetParameter' of undefined at FilterCasesSubgrid
推荐答案
不支持此代码,因此您不应期望它可以工作。使用可直接访问DOM的任何函数(即 window.parent.document.getElementById
)或使用未在 MSDN SDK 不受支持,应避免使用。
This code isnt supported so you shouldnt expect it to work. Using any function which directly accesses the DOM (i.e; window.parent.document.getElementById
) or uses function not defined within the MSDN SDK is unsupported and should be avoided.
但是,鉴于您似乎要做的只是添加过滤器,因此可以通过设置现有的FetchXML查询来实现此目的:
However, given that all you seem to be doing is adding a filter, there are supported methods for doing this by setting an existing FetchXML query:
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);
这篇关于SetParameter(“ fetchXml”,FetchXml)在CRM 2016在线中不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!