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

I have the same question (0)
  • Verified answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at

    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

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 CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans