Dynamics CRM - Součet hodnot
Problém
Potřebuji sečíst hodnoty nákladový položek "Entita Opportunity Product", field "new_externinaklady".
Řešení
Lze použít JavaScript.
function updateTotalAmount() {
if(Xrm.Page.ui.getFormType()==2){
setTimeout(SubGridLoadWait, 1000);
}
}
function SubGridLoadWait() {
var totalExternalCosts = 0;
var gridControl = document.getElementById('opportunityproductsGrid').control;
var ids = gridControl.get_allRecordIds();
for (i = 0; i < ids.length; i++) {
var cellValueExternal = gridControl.getCellValue('new_externinaklady', ids[i]);
var nExternal = parseFloat(getCellData(cellValueExternal));
totalExternalCosts = totalExternalCosts + nExternal;
}
Xrm.Page.getAttribute('new_totalextcosts').setValue(totalExternalCosts);
}
function getCellData(value) {
return value.toString().replace(' Kč', '').replace(' ', '').replace(/[^0-9-,]/g, '');
}
Odkazy
- Calculate total amount in subgrid records in crm 2011
https://dynamicscrminfo.blogspot.cz/2013/05/calculate-total-amount-in-subgrid.html