Hi,
I tried the below code and it seems to be working fine. Can you try this & confirm? You need to change your schema names again as I have used from my trial org.
============
function PrepareSumValues() {
try {
setInterval(function () {
if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("Proposals") != null &&
Xrm.Page.getControl("Proposals") != undefined) {
SumValues();
}
}, 5000);
} catch (ex) {
//Xrm.Utility.alertDialog("Error: " + ex.message);
alert(ex.message);
}
}
function SumValues() {
var rows = Xrm.Page.getControl("Proposals").getGrid().getRows();
var sunAttr1 = 0;
var sunAttr2 = 0;
rows.forEach(function (row, i) {
var rowData = row.getData();
var entity = rowData.getEntity();
var attributes = entity.getAttributes();
var rbs_valortotal = attributes.get("new_itemvalue").getValue();
if (rbs_valortotal !== "") {
rbs_valortotal = rbs_valortotal.replace("R$", "");
sunAttr1 += parseFloat(rbs_valortotal);
}
var rbs_desconto = attributes.get("new_itemdiscount").getValue();
if (rbs_desconto !== "") {
rbs_desconto = rbs_desconto.replace("R$", "");
sunAttr2 += parseFloat(rbs_desconto);
}
});
// ATUALIZA OS CAMPOS NA TELA DE [VENDAS]
Xrm.Page.data.entity.attributes.get("new_totalvalue").setValue(sunAttr1);
Xrm.Page.data.entity.attributes.get("new_totaldiscount").setValue(sunAttr2);
var total = (sunAttr1 - sunAttr2);
Xrm.Page.getAttribute("new_grandtotal").setValue(total);
}
=================