I was trying to figure out how to retrieve values from a subgrid, I was constantly seeing 0 rows from the code. This subgrid has values, however when using the formContext, rather than Xrm.Page the debugger indicates that the code is run prior to subgrid load.
function formOnLoad(executionContext){
var formContext = executionContext.getFormContext();
var grid = formContext.getControl("Products");
grid.addOnLoad(ShowSubGridItems);
}
function ShowSubGridItems(executionContext){
//var formContext = executionContext.getFormContext();
debugger;
//var allRows =formContext.getControl("Products").getGrid().getRows();
var allRows =Xrm.Page.getControl("Products").getGrid().getRows();
var row = allRows.get(0);
var gridEntity = row.getData();
var entity = gridEntity.getEntity();
var entityReference = entity.getEntityReference();
var primeAttributeValue = entity.getPrimaryAttributeValue();
}
As you can see I have commented out the code that has the formContext and changed the function call above, to the current Xrm.Page. The question I have is there something that I am missing here that needs to be in place when using formContext?