web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collecting parent reco...
Power Apps
Unanswered

Collecting parent records from a hierarchical entity

(0) ShareShare
ReportReport
Posted on by 40

I have a hierarchical Questions entity where each record (i.e. Question) has a parent via a M-1 hierarchical relationship and is associated to other records via a M-M non-hierarchical relationship.  Within my application, I'm trying to collect all associated records of a given record AND the parents of those associated records.   Collecting the parents is the problem.

My current approach looks like this:

 

//Step 1: Define context variable from Question gallery selection
UpdateContext(
 {
 locCurrentQuestionRecord:Lookup(Questions,Question=Gallery.Selected.Question)
 }
);

//Step 2: Collect Associated Records via the M-M relationship (this works fine)
ClearCollect(
 colAssociatedQuestions,
 locCurrentQuestionRecord.'Questions (xxxx_AssociatedQuestions)'
);

//Step 3: Collect Parents of Associated Records (see 'Side Note' at the end of this post)
Clear(colParentQuestions);
ForAll(
 RenameColumns(
 colAssociatedQuestions,
 "xxxx_questionid",
 "rcQuestionID"
 ),
 Collect(
 colParentQuestions,
 LookUp(
 [@Questions],
 Question = rcQuestionID
 ).ParentDCQuestion
 )
)

 

I get the following error, specifically on the definition of the context variable 'locCurrentQuestionRecord':

"Multiple levels of many-to-one relationship expansion aren't supported"

 

I tried to avoid a lookup of a lookup (which I understand is not supported) by going this route with my logic above.  Any assistance for working around this error would be appreciated.  Thanks in advance.


Side Note: all this code exists in the OnSelect property of a button which, because of the aforementioned error, doesn't do anything when selected.  If I copy/paste the button, without making any changes to the code, the code (and subsequent code built off these collections) executes exactly as anticipated for several minutes before the error is identified in the recently-pasted button.

Categories:
  • BF-25082302-0 Profile Picture
    40 on at

    Since its been 3 weeks with no bites, perhaps I should simplify my question.  Does the code in my first post truly represent a lookup of a lookup? 

     

    Also, a quick follow for others that see this post - initially, the code in the first post was all executed in a Form.OnSuccess action.  When I moved Step 1 of the code above from the Form.OnSuccess to button that submits the Form (thinking I'm separating the execution of a portion the logic), it seems to work fine.

     

    Given my work around, I suppose a follow question would be, is it true a lookup of a lookup is allowed as long as they are not executed in the same action within PowerApps?

     

    Thanks.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard