Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Calculate total value of a subgrid row

(0) ShareShare
ReportReport
Posted on by

Hi all,

i have the following request. Within the opportunity entity we have a field with the estimated value and a subgrid with all child records which have estimated values as well. Now i created a field which should display the sum all estimated values of the child records which can be found within the subgrid.

I tried this but it didnt work:

function calcsum()
	{

	var grid = document.getElementById(‘opportunity_bundle’); //Subgrid name
	var ids = grid.control.get_allRecordIds();
	var sum = 0.00;
	var cellValue;

	for(i = 0; i < ids.length; i++) {

	var cellValue = grid.control.getCellValue(‘estimatedvalue’,ids[i]);

	//estimatedvalue is the field within the subgrid

	var number = Number(cellValue.replace(/[^0-9\.]+/g,””));
	sum = sum + number;
									}

	alert(sum);
	
	
	
	
	
	
	}


any suggestions?

*This post is locked for comments

  • Verified answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: Calculate total value of a subgrid row

    Hi Alexander,

    By any chance, you tried to achieve this requirement using Roll-Up Field.

    I think Rollup field will do this calculation for you automatically (by doing few simple configurations) without writing the script. The only limitation is, it's an async process, can take time to show updates (Max 1 hr).

    Some examples of rollup fields include:

    • Total estimated revenue of open opportunities of an account
    • Total estimated revenue from open opportunities across all accounts in a hierarchy
    • Total estimated revenue of an opportunity including child opportunities
    • Total estimated value of qualified leads generated by a campaign
    • Number of high priority open cases across all accounts in a hierarchy
    • Earliest created time of all high priority open cases for an account

    Hope it helps:

    https://www.powerobjects.com/2014/10/10/roll-up-fields-dynamics-crm-2015/

    https://technet.microsoft.com/en-us/library/dn832162.aspx?f=255&MSPPError=-2147217396

    If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.


    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

     

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
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans