Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Best way to find latest or newest record for a related entity and populate a lookup on the related enitity.

Posted on by 175

Hi everyone. 

I have two entities, "Cars" and "Reviews". Each car can have multiple reviews and each review can only be related to one car. I have a question about the following. 

Every time a new review is created I need to populate a lookup field on the related car record with the "newest" review. 

How can I go about this, is the WebApi the best way? 

  • Verified answer
    Vijay Tailor Profile Picture
    Vijay Tailor 431 on at
    RE: Best way to find latest or newest record for a related entity and populate a lookup on the related enitity.

    As Per your requirement.

    you can achieve through Custome Workflow as well Plugin.

    After New Record (Review) is created you can get the record Order by "CreatedOn DESC" .

    <fetch top="1" >

     <entity name="review" >

       <order attribute="createdon" descending="true" />

     </entity>

    </fetch>

    Get the GUID and Update in Related(Car) Entity Lookup value with a recent Review Record Guid.

    Hope this will help you.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans