Dynamics crm 在单个视图中显示多个关系记录

Dynamics crm 在单个视图中显示多个关系记录,dynamics-crm,Dynamics Crm,我有一个与母公司账户和组织(均为同一账户实体)存在N:1关系的实体(资产) 在账户实体中,我可以看到通过父账户链接到它的资产,或者通过组织账户链接到它的资产,但不能同时看到两者(据我所知) 我无法将架构更改为将父帐户作为一个实体,将组织帐户作为另一个实体 是否可以在一个子网格中显示这两个关系,或者我仅限于在帐户实体上有两个单独的子网格?您不能立即执行此操作,因为子网格仅支持单个1:N关系。您可以通过创建自定义FetchXml并通过JavaScript修改子网格来实现这一点,因为查询可能是通过Fe

我有一个与母公司账户和组织(均为同一账户实体)存在N:1关系的实体(资产)

在账户实体中,我可以看到通过父账户链接到它的资产,或者通过组织账户链接到它的资产,但不能同时看到两者(据我所知)

我无法将架构更改为将父帐户作为一个实体,将组织帐户作为另一个实体


是否可以在一个子网格中显示这两个关系,或者我仅限于在帐户实体上有两个单独的子网格?

您不能立即执行此操作,因为子网格仅支持单个1:N关系。您可以通过创建自定义FetchXml并通过JavaScript修改子网格来实现这一点,因为查询可能是通过FetchXml实现的,并且可以在高级Find中构建

有关设置子网格的FetchXML的信息,请遵循以下步骤

表单上需要类似于以下内容的加载函数:

function filterSubGrid() {
var accountsGrid = document.getElementById("accounts"); //grid to filter
if (accountsGrid == null) { //make sure the grid has loaded
    setTimeout(function () {
        filterSubGrid();
    }, 2000); //if the grid hasn’t loaded run this again when it has
    return;
}

var contactValue = Xrm.Page.getAttribute("primarycontactid").getValue(); //field to filter by

var contactId = "00000000-0000-0000-0000-000000000000"; //if filter field is null display nothing
if (contactValue != null) {
    var contactId = contactValue[0].id;
}

//fetch xml code which will retrieve all the accounts related to the contact
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
    "  <entity name='account'>" +
    "    <attribute name='name' />" +
    "    <attribute name='address1_city' />" +
    "    <attribute name='primarycontactid' />" +
    "    <attribute name='telephone1' />" +
    "    <attribute name='accountid' />" +
    "    <order attribute='name' descending='false' />" +
    "    <filter type='and'>" +
    "      <condition attribute='primarycontactid' operator='eq' uitype='contact' value='" + contactId + "' />" +
    "    </filter>" +
    "    <link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='accountprimarycontactidcontactcontactid'>" +
    "      <attribute name='emailaddress1' />" +
    "    </link-entity>" +
    "  </entity>" +
    "</fetch>";

accountsGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
accountsGrid.control.refresh(); //refresh the sub grid using the new fetch xml
}
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"  <entity name='new_asset'>" +
"    <attribute name='new_assetid' />" +
"    <attribute name='new_name' />" +
"    <attribute name='createdon' />" +
"    <order attribute='new_name' descending='false' />" +
"    <filter type='or'>" +
"      <condition attribute='new_organizationaccount' operator='eq' value='" + accountId + "' />" +
"      <condition attribute='new_parentaccount' operator='eq'value='" + accountId + "' />" +
"    </filter>" +
"  </entity>" +
"</fetch>";
函数过滤器子网格(){
var accountsGrid=document.getElementById(“accounts”);//要筛选的网格
如果(accountsGrid==null){//请确保已加载网格
setTimeout(函数(){
过滤器子网格();
},2000);//如果网格尚未加载,请在加载后再次运行此操作
返回;
}
var contactValue=Xrm.Page.getAttribute(“primarycontactid”).getValue();//要筛选的字段
var contactId=“00000000-0000-0000-0000-000000000000”;//如果筛选字段为空,则不显示任何内容
如果(contactValue!=null){
var contactId=contactValue[0]。id;
}
//获取xml代码,该代码将检索与联系人相关的所有帐户
var fetchXml=“”+
"  " +
"    " +
"    " +
"    " +
"    " +
"    " +
"    " +
"    " +
"      " +
"    " +
"    " +
"      " +
"    " +
"  " +
"";
accountsGrid.control.SetParameter(“fetchXml”,fetchXml);//将fetchXml设置为子网格
accountsGrid.control.refresh();//使用新的获取xml刷新子网格
}
除了需要类似以下内容的FetchXML外:

function filterSubGrid() {
var accountsGrid = document.getElementById("accounts"); //grid to filter
if (accountsGrid == null) { //make sure the grid has loaded
    setTimeout(function () {
        filterSubGrid();
    }, 2000); //if the grid hasn’t loaded run this again when it has
    return;
}

var contactValue = Xrm.Page.getAttribute("primarycontactid").getValue(); //field to filter by

var contactId = "00000000-0000-0000-0000-000000000000"; //if filter field is null display nothing
if (contactValue != null) {
    var contactId = contactValue[0].id;
}

//fetch xml code which will retrieve all the accounts related to the contact
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
    "  <entity name='account'>" +
    "    <attribute name='name' />" +
    "    <attribute name='address1_city' />" +
    "    <attribute name='primarycontactid' />" +
    "    <attribute name='telephone1' />" +
    "    <attribute name='accountid' />" +
    "    <order attribute='name' descending='false' />" +
    "    <filter type='and'>" +
    "      <condition attribute='primarycontactid' operator='eq' uitype='contact' value='" + contactId + "' />" +
    "    </filter>" +
    "    <link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='accountprimarycontactidcontactcontactid'>" +
    "      <attribute name='emailaddress1' />" +
    "    </link-entity>" +
    "  </entity>" +
    "</fetch>";

accountsGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
accountsGrid.control.refresh(); //refresh the sub grid using the new fetch xml
}
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"  <entity name='new_asset'>" +
"    <attribute name='new_assetid' />" +
"    <attribute name='new_name' />" +
"    <attribute name='createdon' />" +
"    <order attribute='new_name' descending='false' />" +
"    <filter type='or'>" +
"      <condition attribute='new_organizationaccount' operator='eq' value='" + accountId + "' />" +
"      <condition attribute='new_parentaccount' operator='eq'value='" + accountId + "' />" +
"    </filter>" +
"  </entity>" +
"</fetch>";
var fetchXml=“”+
"  " +
"    " +
"    " +
"    " +
"    " +
"    " +
"      " +
"      " +
"    " +
"  " +
"";
获取FetchXML查询的高级查找是:


那么一项资产有一个帐户和一个组织,它们是不同的查找?您需要在帐户中显示具有帐户和组织的资产吗?@Sxntk是的,使用默认的1:N关系,视图允许您选择资产(父项)或资产(组织),我希望它实际上是资产(两者)帐户也有组织吗@Sxntk帐户既是组织又是父项(即,资产和账户之间存在两种N:1关系,一种称为母公司,另一种称为组织)您是否能够提前发现该观点?