【发布时间】: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