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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 5

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,
:)

I have the same question (0)
  • rthompson Profile Picture
    1,532 on at
    RE: Set Lookup Value for Child Based on Parent's Parent Relationship

    Hi JaW17,

    Sounds like you need to build a javascript filterlookup.

  • Suggested answer
    Henry J. Profile Picture
    5,237 on at
    RE: Set Lookup Value for Child Based on Parent's Parent Relationship

    There are multiple way to address it.

    If you want the entity-3 lookup to entity-1 filled in real time for the user, based on the entity-2 value, then you indeed need JavaScript code.
    If you don't need real time, then this can be done through workflow (but that's a legacy technology and I would advise against it) or through a Power Automate Flow.

    I have a warning though: if you change the entity-1 parent from entity-2, the aforementioned mechanisms won't update the lookup value on entity-3.
    So be careful about how data will live in case of reorganizations.

    You could also explore additional ways to potentially achieve the functional goal (display entity-3 grand-child records on the entity-3 records): canvas app, Power Apps Component Framework, web resource, etc.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 77 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 57 Most Valuable Professional

#3
Anthony Blake Profile Picture

Anthony Blake 43 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans