I have tried this, this and this
The goal is to read the subgrid rows in JavaScript in order to get the guids of the rows which could be used in later on. This is done in OnLoad
of the form.
There are a couple of issues here:
- When I use the
addOnLoad
method, it does not call the handler when the form is loaded for the first time. The Grid has to be refreshed or sorted for it to fire the event. Even if I execute the code in OnLoad event, it shows zero rows in the grid although theXrm.Page.getControl("Idebarare").getGrid()
is not null. When it is fired,
getTotalRecordCount
returns -1Xrm.Page.getControl("Idebarare").getGrid().getTotalRecordCount()
This is the code I'm using at the moment. Here I'm calling GetContacts
from the form's onLoad.
function GetContacts(){
Xrm.Page.getControl("Idebarare").addOnLoad(myContactsGridOnloadFunction);
}
function myContactsGridOnloadFunction(){
var allGridEntities = [];
var rows = Xrm.Page.getControl("Idebarare").getGrid().getRows();
rows.forEach(function (row, i) {
allGridEntities.push(row.getData().getEntity());
});
}
So the question is how to get the rows for getting attributes/guids from a subgrid in JavaScript in Dynamics CRM 2015 Update 1 online?