[英]Dynamics CRM2016: cannot read property 'SetParameter' of undefined
I've subgrid on Account form, I am trying to get list of Orders of child contact and then add to subgrid. 我已经在“帐户”表单上建立了子网格,我试图获取子联系人订单的列表,然后添加到子网格中。 So, far I did the following scripts but it throws error that cannot read property 'SetParameter' of undefined .
因此,到目前为止,我已经执行了以下脚本,但是它引发了无法读取undefined属性'SetParameter'的错误。 Can anyone please guide how can I change fetchxml of a subgrid?
谁能指导我如何更改子网格的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();
}
There is a supported no-code way to do this. 有一种受支持的无代码方式可以执行此操作。
If the Contact is not from a lookup, you can 如果联系人不是来自查找,则可以
.fireOnChange()
after filling the field, to invoke the next step) .fireOnChange()
在填充字段后记住.fireOnChange()
,以调用下一步) refresh()
to update the subgrid in the onchange of the contact lookup you just filled refresh()
更新子网格 Then implement the quickview like the two points above. 然后像上面两点一样实现快速查看。
Yes you could use a timeout. 是的,您可以使用超时。 The code would look like:
代码如下所示:
function listOfOrders(contactId) {
var orderSubgrid = window.parent.document.getElementById("orderssubgrid");
if (orderSubgrid == null) {
setTimeout(function () { listofOrders(contactId); }, 2000);
return;
}
// ... the rest of your code
}
If you wanted to try a supported method there were new subgrid methods added to Xrm in 2016. You might want to see if it's possible to use setCurrentView . 如果您想尝试受支持的方法,那么Xrm会在2016年添加新的子网格方法。您可能想看看是否可以使用setCurrentView 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.