Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Create view based on linked entity used twice

(0) ShareShare
ReportReport
Posted on by 71

Hello,

I want to create view which retrieves all activities which are assigned to two Salespeople, which have their two separate fields (lookup) on Account entity:

6457.pastedimage1592582929513v1.png

I'm able only to retrieve activites assigned to one of the representatives:

8715.pastedimage1592583343479v2.png

Here I'm going from 1:N relationship between Activity and User, and then, 1:N relationship between User and Account. This view correctly shows all activities assigned to all people that are Representative 1.

But pulling in the second field, it seems that it takes the inner result of all the clauses (so Activities for Users that are BOTH Representative 1 and 2, which is not a common case:

0172.pastedimage1592585085258v3.png

Here's the XML of the second query:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
  <entity name="activitypointer" >
    <attribute name="subject" />
    <attribute name="activitytypecode" />
    <order attribute="subject" descending="false" />
    <link-entity name="systemuser" from="systemuserid" to="owninguser" alias="aa" >
      <link-entity name="account" from="pr_representative1" to="systemuserid" alias="ab" />
      <link-entity name="account" from="pr_representative2" to="systemuserid" alias="ac" />
    </link-entity>
    <attribute name="ownerid" />
    <attribute name="createdon" />
    <attribute name="activityid" />
  </entity>
</fetch>

I'm not sure what I'm missing here... Is even this scenario achievable using FetchXML? Or do I need to lean towards the plugin or script? Or maybe something different?

My goal is to create a chart counting all of the activities for the both types of representative- maybe there's someting that can be done directly in chart structure?

  • Suggested answer
    LuHao Profile Picture
    40,886 on at
    RE: Create view based on linked entity used twice

    Hi Pocia,

    Group OR cannot be used between entities, only between fields, so we have to create two custom fields and use them to represent the results of the two entities.

    New two Whole Number fields on the User entity, set them as Rollup fileds

    pastedimage1592991742195v1.png        pastedimage1592991894424v4.png

    pastedimage1592991873251v3.png        pastedimage1592991832466v2.png

    When these two Rollup fields are created, they will wait for 12 hours and then automatically calculate the latest results every hour.

    Then in the Advanced Settings, set the filter as follow, use Group OR to connect both Rollup fields.

    pastedimage1592992165508v5.png

    The Rollup field is summarized once every hour, so when you query, the result may not be the latest. We can use Flow to replace the function of Rollup.

    Flow can update the latest summary results in real time

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 87

Overall leaderboard

Product updates

Dynamics 365 release plans