我在帐户表单上进行了子网格,我正在尝试获取子联系人的订单列表,然后添加到子网格。所以,到目前为止,我做了以下脚本,但它引发了错误无法读取未定义的属性'SetParameter'。任何人都可以指导我如何更改子网格的fetchxml?
function listOfOrders(contactId){
var orderFetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
" <entity name='salesorder'>"+
" <attribute name='name' />"+
" <attribute name='customerid' />"+
" <attribute name='salesorderid' />"+
" <attribute name='statecode' />"+
" <attribute name='createdon' />"+
" <order attribute='name' descending='false' />"+
" <filter type='and'>"+
" <condition attribute='customerid' operator='eq' uitype='contact' value='"+contactId+"' />"+
" </filter>"+
" </entity>"+
"</fetch>";
var retrievedOrders = XrmServiceToolkit.Soap.Fetch(orderFetchXml);
var contactId = "";
if(retrievedOrders.length <0)
return;
var viewId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var viewDisName = "Account Orders subgridview";
var layOutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" +
"<row name='result' id='salesorderid'>" +
"<cell name='name' width='300' />" +
"<cell name='statecode' />"+
"<cell name='createdon' />"+
"<cell name='customerid' />"+
"disableSorting='1' />" +
"</row>" +
"</grid>";
var orderSubgrid = window.parent.document.getElementById("orderssubgrid");
//apply layout and filtered fetchXML
orderSubgrid.control.SetParameter("layoutXml", layOutXml);
orderSubgrid.control.SetParameter("fetchXml", orderFetchXml);
//Refresh grid to show filtered records only.
orderSubgrid.control.Refresh();
}
答案 0 :(得分:1)
有一种支持无代码的方法可以做到这一点。
如果联系人不是来自查询,您可以
.fireOnChange()
,以调用下一步)refresh()
更新刚刚填写的联系人查询的onchange中的子网格然后像上面两点一样实施快速浏览。
答案 1 :(得分:0)
是的,您可以使用超时。代码看起来像:
function listOfOrders(contactId) {
var orderSubgrid = window.parent.document.getElementById("orderssubgrid");
if (orderSubgrid == null) {
setTimeout(function () { listofOrders(contactId); }, 2000);
return;
}
// ... the rest of your code
}
如果您想尝试一种受支持的方法,2016年会向Xrm添加新的子网格方法。您可能希望查看是否可以使用setCurrentView。