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
    Arpit Shrivastava 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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans