【问题标题】:CRM 2013 refresh subgrid with fetchxmlCRM 2013 使用 fetchxml 刷新子网格
【发布时间】:2014-11-24 19:01:52
【问题描述】:

在我的场景中,我有一个名为“new_relations”的新实体,其中包含两个字段(account1 和 account2),它们都是对帐户的查找。 在我的帐户表单中,我想在“new_relations”实体中存在的 2 个查找中的任何一个中显示一个包含当前帐户的任何记录的网格。 我已经创建了账户 A 和账户 B;在 new_relations 中创建了 1 条记录,其中 new_relations.account1 = 账户 A 和 new_relations.account2 = 账户 B。 所以,当我打开账户 A 或账户 B 时,我想查看在 new_relations 中创建的记录。

我有以下代码,不幸的是它只在我的子网格中显示 Account´s A 表单中的记录... 有人可以帮忙吗?

function FilterRelacao(){

 var relacoes = document.getElementById("Relacoes");
 var account = Xrm.Page.data.entity.getId();
 var accountname = Xrm.Page.data.entity.attributes.get("name").getValue();

 if(relacoes==null){ 
    setTimeout(function () { FilterRelacao(); }, 2000);  
    return;
 }

 var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical'        distinct='false'>" +
 "<entity name='new_relations'>" +
 "<attribute name='new_type' />" +
 "<attribute name='new_accountid1' />" +
 "<attribute name='new_accountid2' />" +
 "<attribute name='new_relationsid' />" +
 "<order attribute='new_accountid1' descending='true' />" +
 "<filter type='and'>" +
 "<condition attribute='statecode' operator='eq' value='0' />" +
 "<filter type='or'>" +
 "<condition attribute='new_accountid1' operator='eq' uitype='account' uiname='" + accountname+ "' value='" + account + "' />" +
 "<condition attribute='new_accountid2' operator='eq' uitype='account' uiname='" + accountname + "' value='" + account + "' />" +
 "</filter></filter>" +
 "</entity>" +
 "</fetch>";

 relacoes.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid  
 relacoes.control.SetParameter("effectiveFetchXml", fetchXml); //set the fetch xml to the sub grid  
 relacoes.control.Refresh(); //refresh the sub grid using the new fetch xml 

 }

【问题讨论】:

    标签: fetchxml


    【解决方案1】:

    您的 fetch XML 在我看来是正确的。当您设置子网格时,您是否在“数据源”部分设置了“记录”=“所有记录类型”?如果您不这样做,则子网格会将条件附加到您的 fetchxml,以便它仅返回与您指定的特定关系相关的记录。

    【讨论】:

    • 确实是这个问题!就如此容易!非常感谢!
    • 很高兴我能帮上忙,几个月前我也发生过同样的事情 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-09
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多