Read all column values in sub-grid on the form using client API–Dynamics CRM 2016

Microsoft introduced the Xrm.Page object model to interact with the sub-grids on your forms from 2015 Online Update 1 and in CRM 2016 (for on-premise as well). Wonderful isn’t it. You can query the number of rows in the sub-grid, get the primary attribute value, guid and the logical name of each of the record in the sub-grid.

However one big limitation I could find is that, if your sub-grid is having multiple columns, except the primary attribute column, values of no other columns are returned by the existing API. Let us take an example here.

I have a contacts sub-grid on my account entity. The sub-grid has columns – email address, telephone and others.


The requirement here was to read all the column values in sub-grid. The recommended way to get to the grid row data is by the code below.

var rowData = Xrm.Page.getControl(“Contacts”).getGrid().getRows().get(<rowindex>).getData();

var entity = rowData.getEntity();

var entityReference = entity.getEntityReference();

var primaryAttributeValue = entity.getPrimaryAttributeValue();


The above code gets the data for the row at the specified <row index>. You can fetch the entity logical name, the guid of each row data as well as the primary attribute value for each record. But as you can see there is no way to get the other column values like email, telephone etc

Off-course we could get the ID of the data rows and fire a web-api query to get the other column values. And that is supported way.

However getting dirty with the code and playing with it excites me much and here also I tried to dig a bit deep.  Before I dig deeper, a statutory warning which should not be taken lightly.

** All the methods that I would be talking below is not documented in the SDK and hence unsupported and hence might now work in future versions of CRM. So if you implement, please make sure you get an approval from your client. **

Let us take the above code only. Till we get the entity, we would use the same code. However to get the attributes of the entity, we will use the getAttributes method of the entity. So let see how this looks in the developer toolbar.


So attributes returned us a collection of XrmGridEntityAttributes. Interesting isn’t it? So let’s dig a bit deeper.


And there you go! You have the email address and telephone of the contact at your disposal.

Hope this helps!

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under For consulting/ training, drop me a note at or visit our website

4 Responses to Read all column values in sub-grid on the form using client API–Dynamics CRM 2016

  1. Questionn says:

    Hey, this would really help me, but I don’t understand how you implement this. I have a subgrid called Outages_Phonecall on my Contacts page, and I need to access the address rows (not a primary field) so I can map them on google maps.

    Could you give more instruction on how to implement this?

    Thank you.

    • Debajit says:


      The address you are looking for is I guess in the telephone entity. The telephone entity does not have any address fields oob. so I guess it is the custom address fields. If this is the case, I have a sample code which fetches the city from the telphone subgrid (Outages_Phonecalls)

      function checkForPhoneCallAddress() {
      // get the grid in the contact form.
      var phoneCallGrid = Xrm.Page.getControl(“Outages_Phonecalls”).getGrid();

      // get the first Row Data
      var firstRowData = phoneCallGrid.getRows().get(0).getData();

      // get the entity object associated with this data.
      var phoneCallEntity = phoneCallEntity.getEntity();

      // get the city attribute
      var city = phoneCallEntity.getAttributes().get(“new_city”).getValue();

      // logging the value of the city in the console.
      console.log(“City: ” + city);

  2. Questionn says:

    Hey, that’s what I was doing, but I found it only works within an entity form. It doesn’t seem to work on a Dashboard page. 

    Even document.getElementByID(“name”).control fails on a Dashboard.

    Do you know how to by-pass this? Just trying to count how many rows there are.

  3. Excellent Job brother…….i like your way of thinking….

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: