Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get fields from child entity and set it to the parent entity fields

(0) ShareShare
ReportReport
Posted on by 74

Hello,

I have two entities called booking and payment list and there is 1:N relation between them.

Now i want to get latest record from payment list entity which is child entity of booking.

Payment list entity has multiple records and i want only the last record(who has payment date) and that data should be set to the parent entity (booking) fields.

I want to achieve this using javascript.

please help me in this.

Thank You.

*This post is locked for comments

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    replied here : community.dynamics.com/.../309283  

  • Suraj Jadhav Profile Picture
    74 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    Hello ,

    Do you have any idea about how we can calculate sum of amount that we retrieve based on particular charge type  ?

  • Suraj Jadhav Profile Picture
    74 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    Hello, Rawish

    My problem is solved now, it was my mistake i have not  check the condition.

    8004.Capture11.PNG

    Thank You.

  • Community Member Profile Picture
    on at
    RE: How to get fields from child entity and set it to the parent entity fields

    .. why JS and not just Rollup using max of date?
    Another solution would be on Change of the date to write it to the parent field using Workflow...

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    Hi Suraj,

    It is working fine for me even for custom date.

    please try to clear the cache and try in inprivate.

  • Suraj Jadhav Profile Picture
    74 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    My date field is custom field not created on

    and i just debug the cord and  date field taking same value as 2019-02-16

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    this works for me :

    04783.2.png

    rest builder - script , first result:

    04783.2.png

  • Suraj Jadhav Profile Picture
    74 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    Hello Rawish ,

    I have total 8 records and i am sorting data on Due date

    1 record has due date 23-04-2016

    2 record 30-08-2017

    3 record  14-09-2016

    4th record 13-11-2016

    5th  30-11-2016

    6th 30-12-2016

    7th 16-12-2016

    8th 09-02-2019

    and i want 8th record first

    i am getting all dates as 2019-02-16

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    Hi Suraj,

    How did you know its not sorting. Did you debug the script  to see what record you are getting on [0] position?

  • Suraj Jadhav Profile Picture
    74 on at
    RE: How to get fields from child entity and set it to the parent entity fields

    Hello Rawish,

    Thank you it's work but it's not sorting descending by date

    i have done it using rest builder please find below code line

    &$orderby=psm_duedate desc", true);

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans