我使用了类似的代码来使用自定义FetchXML加载网格,但我无法使用这个。我得到一个Out of Stack空间错误。我试图改变计时器,但这没有帮助。我不知道CRM中有什么变化吗?
函数UpdateSubGridRelatedMatters(){
var grid = document.getElementById("RelatedMTIGrid");
//If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding
//Included extra null check as a rollup 5 fix
var relatedMatterID = Xrm.Page.data.entity.attributes.get("sage_relatedmatter").getValue()[0].id;
//if (relatedMatterID != null) {
//Update the fetchXML that will be used by the grid.
var fetchXml = "";
fetchXml += "<fetch version=\" 1.0\" output-format=\" xml-platform\" mapping=\" logical\" distinct=\" false\" >";
fetchXml += "<attribute name=\" sage_mtiid\" />";
fetchXml += "<attribute name=\" sage_name\" />";
fetchXml += "<attribute name=\" createdon\" />";
fetchXml += "<attribute name=\" sage_scientistisconsultant\" />";
fetchXml += "<attribute name=\" sage_secondlab\" />";
fetchXml += "<attribute name=\" sage_scientisthascfn\" />";
fetchXml += "<attribute name=\" sage_scientist\" />";
fetchXml += "<attribute name=\" sage_redlines\" />";
fetchXml += "<attribute name=\" sage_providermatterid\" />";
fetchXml += "<attribute name=\" sage_organizationcontact\" />";
fetchXml += "<attribute name=\" sage_organization\" />";
fetchXml += "<attribute name=\" sage_matterid\" />";
fetchXml += "<attribute name=\" sage_origin\" />";
fetchXml += "<attribute name=\" sage_materialtype\" />";
fetchXml += "<attribute name=\" sage_hostmatterid\" />";
fetchXml += "<attribute name=\" sage_hostcontact\" />";
fetchXml += "<attribute name=\" sage_host\" />";
fetchXml += "<attribute name=\" sage_executedbyhhmi\" />";
fetchXml += "<attribute name=\" createdby\" />";
fetchXml += "<order attribute=\" createdon\" descending=\" false\" />";
fetchXml += "<order attribute=\" sage_name\" descending=\" false\" />";
fetchXml += "<filter type=\" and\" >";
fetchXml += "<condition attribute=\" sage_relatedmtiid\" operator=\" eq\" value=\" " + relatedMatterID + "\" />";
fetchXml += "</filter>";
fetchXml += "</entity>";
fetchXml += "</fetch>";
if (grid == null || grid.readyState != "complete") {
//The subgrid hasn't loaded, wait 1 second and then try again
setTimeout(UpdateSubGridRelatedMatters(), 3000);
return;
}
debugger;
//Inject the new fetchXml
grid.control.SetParameter("fetchXml", fetchXml);
//Force the subgrid to refresh
grid.control.refresh();
// }
}
答案 0 :(得分:2)
您正在调用UpdateSubGridRelatedMatters并将结果而不是函数本身作为参数传递给setTimeout,这将使您进入递归循环,从而实现堆栈溢出。
更改
setTimeout(UpdateSubGridRelatedMatters(), 3000);
要
setTimeout(UpdateSubGridRelatedMatters, 3000);