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