I use this code
function countdistinctitems() {
var invoiceSubgrid = Xrm.Page.getControl("invoicedetailsgrid");
var grid = invoiceSubgrid.getGrid();
var filteredRecordCount = grid.getTotalRecordCount();
var Rows ;
var entity ;
var mainteam ;
for(i=0;i < filteredRecordCount;i++) {
Rows(i) = grid.getRows().get(i).getData();
entity(i) = Rows(i).getEntity();
mainteam(i) =entity(i).getControl("new_mainteam").getValue();
}
mainteam.sort();
var count = 1;
for (j=0;j < mainteam.length;j++) {
if (mainteam[j] != mainteam[j+1]) {
count +=1
}
}
Xrm.Page.data.entity.attributes.get("new_field").setValue(count);
}
but I get this error:
unable to get property getgrid of undefined or null refrence;
why subgrid returns null?????
please help me!!!
*This post is locked for comments