My Dynamics 365 CRM is in Version 9 and there is not enough reference on this issue I am facing. I am looking for a custom script to get a sum of a column of a subgrid in an entity. I have an entity with a field name "total_amount", on that entity , i have a form with a subgrid referenced to another entity, which possess the records where i have product lines in it. How do i sum up the price of the product line, and insert the sum into "total_amount" field?
Currently i'm trying to use the gridcontext to achieve this but there isnt proper reference as to how do i use it to extract the column value and total it up.
I found this code but its only for older version of CRM :
setTimeout(calcCostoTotal, 3000);
}
function calcCostoTotal() {
var grid = document.getElementById(‘Deals’);
var ids = grid.control.get_allRecordIds();
var sum = 0.00;
var cellValue;
for(i = 0; i < ids.length; i++) {
var cellValue = grid.control.getCellValue(‘NAME OF THE FILED THAT IS BEING SUMMED’,ids[i]);
var number = Number(cellValue.replace(/[^0-9\.]+/g,”));
sum = sum + number;
}
Xrm.Page.data.entity.attributes.get(“NAME OF THE FILED THAT THE SUM IS GOING TO”).setValue(sum);
}
*This post is locked for comments
I have the same question (0)