cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gymcode
Post Partisan
Post Partisan

Get (Many-to-Many) Associated Entity Records from User Record

Is it possible to get a list of associated entity records in Users profile?

- (Many-to-Many) Relationship between User and Area entity.

gymcode_0-1705899662837.png

gymcode_0-1705899735344.png


Objective:
- Get list of Areas associated to current logged in user, or
- (not preferable) Get list of Users associated to an Area

----------

Something along the line of 

 

Filter(Areas, User().FullName in Areas.'AuthorisedUsersSubgrid'.FullName)

 

where 'AuthorisedUsersSubgrid' is the unique name of the subgrid displaying associated users record in an Area record.

gymcode_0-1705902099535.pnggymcode_1-1705902117955.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ivan_apps
Memorable Member
Memorable Member

Yes it's possible to get N:N relationship data, however it is not available directly from the Power Apps Canvas UI.

What you would have to do is create an instant Power Automate flow (with Power Apps v2 trigger) and query the intersect table on a dataverse List Rows action. The intersect table may not be directly visible, but you can always enter the table name directly.

 

Example table name in the N:N relationship (teamroles) for Teams to Security Roles -

ivan_25_0-1705906506776.png

 

---------
If I helped you solve your issue, please mark it as a solution or give it a like!

View solution in original post

13 REPLIES 13
ivan_apps
Memorable Member
Memorable Member

Yes it's possible to get N:N relationship data, however it is not available directly from the Power Apps Canvas UI.

What you would have to do is create an instant Power Automate flow (with Power Apps v2 trigger) and query the intersect table on a dataverse List Rows action. The intersect table may not be directly visible, but you can always enter the table name directly.

 

Example table name in the N:N relationship (teamroles) for Teams to Security Roles -

ivan_25_0-1705906506776.png

 

---------
If I helped you solve your issue, please mark it as a solution or give it a like!

Hi @ivan_apps , thank you for the suggestion.

1) I have created a relationship between Users -> Areas

gymcode_0-1705909860348.png

 

2) After which, I tried to create an intersect table because there is no fields during table creation that allows me to specify the Many-to-Many relationship.

gymcode_1-1705910096839.pnggymcode_2-1705910107618.png

 

Even after creating the new table, I couldn't specify the Many-to-Many relationship anywhere.

gymcode_4-1705910428091.png

 


3) I then created an Instant Cloud Flow with PowerApps (V2), and a List Row action querying the relationship table name, but an error was encountered.

 

Request to XRM API failed with error: 'Message: Flow client error returned with status code "BadRequest" and details "{"error":{"code":"InvalidOpenApiFlow","message":"Flow save failed with code 'DynamicOperationRequestClientFailure' and message 'The dynamic operation request to API 'commondataserviceforapps' operation 'GetMetadataForGetEntity' failed with status code 'NotFound'. This may indicate invalid input parameters. Error response: {\"error\":{\"code\":\"EntityNotFound\",\"message\":\"Could not find table with name 'hsl_systemuser_hsl_area'.\"}}'."}}". Code: 0x80060467 InnerError: '.

 

gymcode_0-1705911126689.png

Failed to retrieve dynamic outputs. As a result, this operation's outputs might not be visible in subsequent actions. Error details: Could not find table with name 'hsl_systemuser_hsl_area'.


I am lost at this current stage and uncertain if the above steps are correctly done.

I seek your advice. Thank you.

gymcode
Post Partisan
Post Partisan

@ivan_apps I have updated my attempt details and screenshot above, for your advice at your availability. Thank you.

When you create a Many-to-many relationship an intersect table is automatically created. In your screenshot #1 you can see the intersect table name is hsl_systemuser_hsl_area. No need to manually create the intersect table after creating a N:N relationship.

 

Now your flow error does look like an issue - have you published all customizations? Power Automate won’t find the relationship unless it’s published.  There are other things to check but first ensure that you can see the many-to-many relationship on the list of relationships for systemuser or Areas

---------
If I helped you solve your issue, please mark it as a solution or give it a like!

Hi @ivan_apps , thank you for your response.

I have Published All Customizations again, but the table not found error is still shown.

In both User and Area entity, I can see the Many-to-Many relationship and both Relationship table names are the same.

1) User

gymcode_2-1705998041747.png

gymcode_3-1705998089720.png


2) Area

gymcode_1-1705998030084.png

gymcode_4-1705998137904.png

 

Let me check other potential areas for this issue....

Ok I dug into it further - your tables might be different but the method should be the same. 

 

XrmToolBox has a tool called FetchXML builder, I used that tool to generate the appropriate Power Automate filters as described here: https://dynamicsbackpage.wordpress.com/2019/12/27/using-expand-query-in-power-automate-with-cds/

 

You can build your query with the tool and connect it directly to your tenant. End result is you get the query exactly as you need to enter it in Power Automate.

 

Basically instead of querying the intersect table (it was possible in code and SQL in the past) - you will need to use the $expand property in Power Automate.

 

this is what it would look like, if you are retrieving the Users (systemuser) table for a specific person and returning all associated teams (teammembership table): 

teammembership_association($select=name)

In the case above, I'm just interested in the team name property, so that's the $select statement.

 

The flow output will then have all your teams, and you can iterate through them as needed.

ivan_25_0-1706021248815.png

 

Hope it helps!

---------
If I helped you solve your issue, please mark it as a solution or give it a like!

Hi @ivan_apps , thank you for the assistance. I have attempted to FetchXML Builder via XRMToolBox.

I configured the relationship and linked-entities, 'systemuser' and 'hsl_area', and Result View does show the 2 associated records.

gymcode_1-1706064228980.png


On the step of retrieving Power Automate parameters, it displays the following error:

 

Cannot find metadata for relation systemuser.systemuserid => hsl_systemuser_hsl_area.systemuserid

 

gymcode_2-1706082124507.png


Am I missing a configuration or step anywhere while creating the relationship? 😞

Yes you have to add an alias because there are multiple systemuserid columns from the relationships. Add any text on the 'Alias' field and it will prefix all attributes from that joined table with that alias to uniquely identify it. 

Don't forget to do another join to retrieve the properties from hsl_area table, and give that an Alias as well.

 

In my example below - the alias for the teammembership table was "tm" and the next join to the team table had an alias of "t" - so then retrieving the team name has a column name of "t.name"

 

ivan_25_0-1706099929141.png

 

---------
If I helped you solve your issue, please mark it as a solution or give it a like!

Hi @ivan_apps , thank you for your examples. I followed the steps but encountered an error during Flow Run.
_________________________________________________________________________________________________________________________
Objective
Get all'Areas'.'hsl_name' associated with a systemuser (Many-to-Many relationship)
_________________________________________________________________________________________________________________________
Steps Taken
1) Verified 3 records of 'Areas' associated to 'SystemUser' are shown in Result View and CRM user record.

gymcode_2-1706112938386.png

gymcode_1-1706112056189.png

Table : Areas
Columns : hsl_name
Filter : (hsl_systemuser_hsl_area/any(o1:(o1/systemuserid ne null)))
Expand : hsl_systemuser_hsl_area($select=systemuserid)
Fetch Xml :

 

<fetch top="50">
  <entity name="hsl_area">
    <attribute name="hsl_name" />
    <link-entity name="hsl_systemuser_hsl_area" from="hsl_areaid" to="hsl_areaid" link-type="inner" alias="Area" intersect="true">
      <filter>
        <condition attribute="systemuserid" operator="eq" value="015fde02-eaad-ee11-a569-000d3ac71097" uitype="hsl_systemuser_hsl_area" />
      </filter>
      <link-entity name="systemuser" from="systemuserid" to="systemuserid" link-type="inner" alias="SystemUser" intersect="true">
        <attribute name="systemuserid" />
      </link-entity>
    </link-entity>
  </entity>
</fetch>

 

2) Input the values into 'List Rows' action in Power Automate (except FetchXML)

gymcode_3-1706113060975.png

Columns: hsl_name
Filter Rows: systemuserid eq '015fde02-eaad-ee11-a569-000d3ac71097'
Expand Query: hsl_systemuser_hsl_area($select=systemuserid)
_______________________________________________________________________________________________________________________
Results
However, the Test Flow failed with the following error:

 

Could not find a property named 'systemuserid' on type 'Microsoft.Dynamics.CRM.hsl_area'.

 

gymcode_4-1706113170697.png


- Raw Inputs:

 

{
    "host": {
        "connectionReferenceName": "shared_commondataserviceforapps",
        "operationId": "ListRecords"
    },
    "parameters": {
        "entityName": "hsl_areas",
        "$select": "hsl_name",
        "$filter": "systemuserid eq '015fde02-eaad-ee11-a569-000d3ac71097'",
        "$expand": "hsl_systemuser_hsl_area($select=systemuserid)"
    }
}

 


- Output:

 

{"statusCode":400,"headers":{"Cache-Control":"no-cache","x-ms-service-request-id":"ff0e81f8-94d0-4525-b06a-e74f505f2aa3,79f98285-d811-48d4-925a-6532056d82d0","Set-Cookie":"ARRAffinity=f69b0981f5a81304924bfd10aa1623f09102b22407fefd8f03be2ac4731febd1eb29bb4b19df1459d2ea781b605f33064b9fea1f144b525b9d7676625c4ffb5408DC1CFC52A7AA48447460282; path=/; secure; HttpOnly,ReqClientId=dd759e0f-207a-4f35-919e-23b0875381cf; expires=Wed, 24-Jan-2074 16:18:42 GMT; path=/; secure; HttpOnly,ARRAffinity=f69b0981f5a81304924bfd10aa1623f09102b22407fefd8f03be2ac4731febd1eb29bb4b19df1459d2ea781b605f33064b9fea1f144b525b9d7676625c4ffb5408DC1CFC52A7AA48447460282; path=/; secure; HttpOnly","Strict-Transport-Security":"max-age=31536000; includeSubDomains","REQ_ID":"79f98285-d811-48d4-925a-6532056d82d0,79f98285-d811-48d4-925a-6532056d82d0","CRM.ServiceId":"framework","AuthActivityId":"dd772241-5fe3-4e45-b734-0950e80f4e89","x-ms-dop-hint":"48","x-ms-ratelimit-time-remaining-xrm-requests":"1,200.00","x-ms-ratelimit-burst-remaining-xrm-requests":"5999","OData-Version":"4.0","X-Source":"1291914420521215112089418157832371953740931791032081821117114173209416768421936,19523217291124581639816413317031501961424723461146359207143321612512039235316448","Public":"OPTIONS,GET,HEAD,POST","Date":"Wed, 24 Jan 2024 16:18:41 GMT","Allow":"OPTIONS,GET,HEAD,POST","Content-Type":"application/json; odata.metadata=full","Expires":"-1","Content-Length":"126"},"body":{"error":{"code":"0x0","message":"Could not find a property named 'systemuserid' on type 'Microsoft.Dynamics.CRM.hsl_area'."}}}

 

_________________________________________________________________________________________________________________________

 I request your assistance to see which part of the steps above did I made a mistake in.

Thank you very much, I appreciate your patience on handling my lengthy question and responses.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (921)