1

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:

  1. 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 the Xrm.Page.getControl("Idebarare").getGrid() is not null.
  2. When it is fired, getTotalRecordCount returns -1

    Xrm.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?

Community
  • 1
  • 1
A.K
  • 505
  • 1
  • 12
  • 30
  • I think the issue you're experiencing here is related to the async loading nature of the grids. Have you tried explicitly calling the .refresh method after adding the onload handler? I know it's not really clean to force a Grid refresh during the form onload, but I think it might do the trick. – Nathan Jul 20 '16 at 07:56

0 Answers0