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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Field that counts the number of related records in a child entity

(1) ShareShare
ReportReport
Posted on by 8
Hi,
 
I want to add in a field (Number of Lost Project Reasons) on the the form, see screenshot attached. 
It should count the number of records in the sub-grid "Lost Project Reasons". In this case, 2
 
What is the easiest/best way for me to do this?
 
Thanks you for your time,
Ollie
cnt.PNG
Categories:
I have the same question (0)
  • Suggested answer
    ManoVerse Profile Picture
    1,240 Super User 2026 Season 1 on at
    Here are the cleanest options listed from simplest(no code) to most flexible I would say. You have to decide best based on your requirement :

    Rollup Field ( Simplest) 
    Use it when you want a simple, no‑code count of child records. , Don’t use it when you need instant updates,rollups refresh on a schedule, not in real time.
    Power Automate Flow
    Use it when you want near‑real‑time updates without coding.
    Form JavaScript ( need bit code)
    Use it when you want the count to update instantly on the form as users interact.  Don’t use it when the value must stay correct server‑side, in views, reports, or automation, JS only updates the UI unless saved.
    Plugin (C#) ( need code)
    Use it when you need the most reliable, real‑time, server‑side update every time a record is added or removed. Don’t use it when you want a simple, admin‑friendly solution, plugins require deployment, dev skills, and ALM overhead.
     
    Let me know if you need help for steps to implement any approach.
     
    Regards,
    Manoj
    If this answer helped you, please consider marking it as Verified, it really helps others in community
     
  • Suggested answer
    11manish Profile Picture
    888 on at
    The easiest and most effective way to display the count of related records in a field on a Dynamics 365 form is to use a Rollup Field.

    This is an out-of-the-box, no-code solution that allows you to aggregate data from child records directly into a parent record.
  • Suggested answer
    Niki Patel Profile Picture
    114 on at

    Hi,

    For this requirement, there are two possible approaches we can take to populate the “Number of Lost Project Reasons” field based on the subgrid records:

    Option 1: Plugin (Recommended Approach)

    We can implement a server-side plugin on the Lost Project Reason entity (on Create and Delete).

    The plugin will:

    • Count the number of related records

    • Update the “Number of Lost Project Reasons” field on the parent record

    Benefits:

    • Real-time and always accurate

    • Works for all scenarios (UI, imports, integrations, Power Automate, etc.)

    • Does not depend on form or subgrid loading

    This is the most reliable and scalable solution.

     

    Option 2: Rollup Field + Plugin (Hybrid Approach)

    We can create a Rollup Field on the parent entity to count related records automatically.

    However, rollup fields are calculated asynchronously, so the value may not update immediately.

    To improve this, we can:

    • Use the rollup field for counting logic

    • Add a plugin to force recalculation (using CalculateRollupFieldRequest) whenever a related record is created or deleted

    Benefits:

    • Uses out-of-the-box functionality

    • With plugin support, provides near real-time updates

    Limitation:

    • Slightly more complex due to dependency on rollup + plugin

    If this answer helped you, please consider marking it as Verified, it really helps others in community

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
Subra Profile Picture

Subra 146

#2
BillurSamdancioglu Profile Picture

BillurSamdancioglu 85 Most Valuable Professional

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 84 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans