Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Create view based on linked entity used twice

Posted on by 65

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
    LuHao 40,872 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans