Dynamics crm FetchXML查询,返回当前用户下属拥有的所有记录

Dynamics crm FetchXML查询,返回当前用户下属拥有的所有记录,dynamics-crm,dynamics-crm-online,fetchxml,Dynamics Crm,Dynamics Crm Online,Fetchxml,我有一个使用管理层次结构组织员工(用户)的组织。他们想给经理们看一看。此视图应返回由当前用户管理的用户、由当前用户管理的用户或由当前用户管理的用户管理的用户拥有的所有打开的Opportunity。这三个级别是我们所需要的 我已经开发了一个FetchXML查询,它返回由当前用户管理的用户拥有的所有项目 <entity name="opportunity"> <attribute name="name" /> <attribute name="est

我有一个使用管理层次结构组织员工(用户)的组织。他们想给经理们看一看。此视图应返回由当前用户管理的用户、由当前用户管理的用户或由当前用户管理的用户管理的用户拥有的所有打开的Opportunity。这三个级别是我们所需要的

我已经开发了一个FetchXML查询,它返回由当前用户管理的用户拥有的所有项目

  <entity name="opportunity">
    <attribute name="name" />
    <attribute name="estimatedvalue" />
    <attribute name="statuscode" />
    <attribute name="parentcontactid" />
    <attribute name="parentaccountid" />
    <attribute name="opportunityid" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
    <link-entity name="systemuser" from="systemuserid" to="owninguser" link-type="inner" alias="ad">
      <filter type="and">
        <condition attribute="parentsystemuserid" operator="eq-userid" />
      </filter>
    </link-entity>
  </entity>
</fetch>

下面是一个也不起作用的替代方案。这将返回由当前用户管理的某人拥有的所有机会,当前用户自行管理这些机会

  <entity name="opportunity">
    <attribute name="name" />
    <attribute name="estimatedvalue" />
    <attribute name="statuscode" />
    <attribute name="parentcontactid" />
    <attribute name="parentaccountid" />
    <attribute name="opportunityid" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
    <link-entity name="systemuser" from="systemuserid" to="owninguser" link-type="inner" alias="aa">
      <filter type="and">
        <condition attribute="parentsystemuserid" operator="eq-userid" />
      </filter>
      <link-entity name="systemuser" from="systemuserid" to="parentsystemuserid" link-type="inner" alias="ab">
        <filter type="and">
          <condition attribute="parentsystemuserid" operator="eq-userid" />
        </filter>
        <link-entity name="systemuser" from="systemuserid" to="parentsystemuserid" link-type="inner" alias="ac">
          <filter type="and">
            <condition attribute="parentsystemuserid" operator="eq-userid" />
          </filter>
        </link-entity>
      </link-entity>
    </link-entity>
  </entity>
</fetch>

您可能对以下所有者操作员感兴趣:

  • eq useroruserhierarchy
  • eq useror userhierarchyandteams
  • eq用户或用户团队
  • eq用户团队
根据您的描述,您可能需要
eq useroruserhierarchy

您可以这样使用它:

<fetch top="50" >
  <entity name="opportunity" >
    <all-attributes/>
    <filter>
      <condition attribute="ownerid" operator="eq-useroruserhierarchy" />
    </filter>
  </entity>
</fetch>