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 / Set Lookup Value for C...
Power Apps
Answered

Set Lookup Value for Child Based on Parent's Parent Relationship

(0) ShareShare
ReportReport
Posted on by 15

Hey Everyone,
 
I am wondering what the best way is to set the value of a look up field for a CDS entity. This lookup field needs to be set to the entity's grandparent. The structure is, entity-1 is the parent to entity-2. entity-1 can have many entity-2s. Entity-2 can only have one Entity-1. Entity-2 is the parent for entity-3. Entity-2 can have many entity-3s. Entity-3 can only have one Entity-2. Currently the relationship for entity-1 to entity-3 is a lookup field on entity-3 that looks up entity-1. This lookup needs to lookup to the same entity-1 that is the parent for entity-2 which is the parent to entity-3. I do not know a good way to have this set automatically / by default. I need this because I need a subgrid that shows all of the entity-3s that are owned by entity-1. Entity-1 owns both entity-2 and entity-3, but entity-2 also owns and overall affects entity-3.
What would be the best way to set this relationship / lookup field?
Thanks, 🙂

Categories:
I have the same question (0)
  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Jackw ,

    Do you want to set the LookUp field value within your Entity3 to the same Entity1 record which is the same parent to Entity 2 and Entity3?

     

    I have made a test on my side, please consider take a try with the following workaround:

    You could generate a canvas app based on your Entity3, then add your Entity1 and Entity2 as data sources into this app.

    Set the OnStart property of App to following:

    ClearCollect(
     Entity3ToEntity1Collection,
     ForAll(
     Entity3,
     Entity3ToEntity1LookUpField.'Unique Identifier Column'
     )
    );
    ClearCollect(
     Entity2ToEntity1Collection,
     ForAll(
     Entity2,
     Entity2ToEntity1LookUpField.'Unique Identifier Column'
     )
    );
    // SameParentCollection is used to store the same parent identifier GUID value from Entity1 for Entity2 and Entity3
    Clear(SameParentCollection);
    ForAll(
     Entity2ToEntity1Collection,
     If(
     Value in Entity3ToEntity1Collection.Value,
     Collect(SameParentCollection, Value)
     )
    )

    Then you could go to the Edit form, unlock the Entity3ToEntity1LookUpField data card, set the Items property of the ComboBox to following:

    Filter(Choices([@Entity3].Entity3ToEntity1LookUpField), 'Unique Identifier Column' in SameParentCollection)

    please re-load your app (fire the OnStart property of App), then the same parent record options for Entity2 and Entity3 from Entity1 would be populated into this ComboBox.

     

    If you want to achieve your needs in Model-Driven app, I afraid that there is no way to achieve your needs currently. Currently, there is no way to configure one relationship based on another relationship in CDS.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Is there any way to make this happen in Model apps? Any sort of workaround would be helpful.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard