web
You’re offline. This is a read only version of the page.
close
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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans