Skip to main content

Notifications

Community site session details

Community site session details

Session Id : f7s/KRXP3n8OhuxCiV67BL
Power Apps - Microsoft Dataverse
Unanswered

Retrieving polymorphic records using 'In' operator

Like (0) ShareShare
ReportReport
Posted on 1 Jun 2020 19:19:54 by 5

For my custom entity record, I'm trying to fetch related Contact records linked through Connections entity.

CustomEntity <--> Connections <--> Contacts

 

Currently using ForAll to fetch data which works, but I want to use the 'In' operator to improve performance (PowerApps experimental feature, currently at version 3.20051.17).

Here's the code for the currently working approach:

//Fetch connections for my selectedRecord

ClearCollect(
      ConnectionsForEng,
      Filter(
               Connections,
               'Connected From' = selectedRecord && Status = 'Status (Connections)'.Active
              )
      );

 

//then fetch Contacts using ForAll:

ClearCollect(
         ContactsForEng,
                 ForAll(
                           ConnectionsForEng,
                           AsType(
                                        'Connected To',
                                        [@Contacts]
                                       )
                             )
                 );

 

Have been playing around with disambiguation operator and ShowColumns for hours now, but the field "_record2id_value" in Connections does not give me a straight up collection of GUIDs for this record2id column.

 

  • Community Power Platform Member Profile Picture
    on 03 Jun 2020 at 13:55:40
    Re: Retrieving polymorphic records using 'In' operator

    Connections is one of those Out of the Box options that is very, very, very specific to it's design.

     

    In Enterprise engagements rhen we really want to pivot we tend to use a Configured Many to Many relationship where we get to manage and (report on easily) the intersecting entity. 

    It is also a critical variable when working with 10s or 100s of integrations where data has to be passed to systems that are configured differently. 

     

    I suspect this doesn't answer your question 😞 , but if you get the chance to do more architecture and design moving forward consider additional options in architecting the system. 

     

    @microsoft Note: Connections Fits/Gaps is most likely needed documentation to add to the huge and wonderful DOCS library.

  • pluthra Profile Picture
    5 on 02 Jun 2020 at 20:01:13
    Re: Retrieving polymorphic records using 'In' operator

    @AMoon  yes that's precisely right, the Connected To field seems to be stored as an inaccessible object (in the app maker) , even though I took a fiddler trace and saw that the actual GUID values were being retrieved in the first API call that goes out

     

    Shouldn't the GUIDs be available to use as they are already retrieved?

    Is my best option to continue using ForAll? 

  • AaronMoon Profile Picture
    43 on 02 Jun 2020 at 12:01:33
    Re: Retrieving polymorphic records using 'In' operator

    Hi @pluthra, I believe that due to the fact that the linked Connected From and To records are stored as reference objects by Canvas Apps - You will still have to make a separate call for each connection record in order to get the GUID value of the Contact. So even if you switch to using the In operator you have to first fix that issue. Let me know if this makes sense or if you know something I don't! Also - would like to see what you have tried with the In operator if you have tried something there.

  • pluthra Profile Picture
    5 on 02 Jun 2020 at 08:18:05
    Re: Retrieving polymorphic records using 'In' operator

    Hi @AMoon thanks for the quick response, the query you have still uses the ForAll operator, causing one CDS call per Connection record to get the corresponding Contact record. This causes performance issues when the count of connections is say 15+ as the app fires 15 calls to populate the list, my connection count can go up to a higher number.

     

    My goal is to get all contacts for the Connections in my collection in a single CDS API call from my powerapp, hence looking for a way by using the In operator which is now delegable as an experimental feature.

     

     

  • AaronMoon Profile Picture
    43 on 01 Jun 2020 at 21:18:21
    Re: Retrieving polymorphic records using 'In' operator

    Hi @pluthra, I tried quickly copying what you are trying to do. I did not use the IN operator, but I'm not seeing any delegation issues with this formula at the moment. Check out my formula below - I combine your two steps into one. If all you need is the GUIDs then for simplicity you can just add .Contact to the end of your AsType() to simply return a table of GUID values.  Let me know if this fits what you are looking for? 

    ClearCollect(ContactsForEng, ForAll(Filter(Connections, 'Connected From' = selectedRecord, Status = 'Status (Connections)'.Active), AsType('Connected To', Contacts).Contact))
    This formula returns a one column table with the GUIDs. 

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Microsoft Dataverse

#1
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

#2
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 9

Overall leaderboard

Featured topics