Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Henry J. Profile Picture
    Henry J. 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.

  • rthompson Profile Picture
    rthompson 1,530 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.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,602 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,340 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans