I have found a simple JS function to take the values of some children, sum them and set a field on my parent form with that value.
My JS is :-
function timeout(){
setTimeout(calcCostoTotal, 3000);
}
function calcCostoTotal() {
var grid = document.getElementById(‘Services’);
var ids = grid.control.get_allRecordIds();
var sum = 0.00;
var cellValue;
for(i = 0; i < ids.length; i++) {
var cellValue = grid.control.getCellValue(iss_salesprice,ids[i]);
var number = Number(cellValue.replace(/[^0-9\.]+/g,”));
sum = sum + number;
}
Xrm.Page.data.entity.attributes.get(ava_tempgrossvalue).setValue(sum);
}
And I have added the library to the form and called calcCostoTotal OnLoad but I get an undefined error.
Services is the name of a view on the form which shows the children
iss_salesprice is the child value
ava_tempgrossvalue is the parent field
Can anyone spot my mistake?
If this is an inappropriate approach can anyone point me in the direction of a better one please?
Thank you in advance
*This post is locked for comments
I have the same question (0)