web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Getting related data shown in subgrid with JavaScript

(0) ShareShare
ReportReport
Posted on by 15

Hi all,

I'm trying to create a custom button in a form subgrid that copies the data from one of the columns.

It'd be easy if the property I want to copy was from the directly-related entity, but in my case, the column comes from a level below (linked to the related entity), so it's not listed on the row.getData().getEntity().attributes.getAll();

@Edit: Example

So here I have a view on the Contact form showing the associated Accounts.

The second column is a lookup field of the entity for its parent account.
The third column is the email address of its parent account. That is the value I want.

Annotation-2020_2D00_05_2D00_22-085920.jpg

I created a ribbon button for this subgrid passing the SelectedControl as the parameter, with the following code:

function getEmail(control) {
    var rows = control.getGrid().getRows();
    rows.forEach(function (row, i) {
        var data = row.getData().getEntity().attributes.getAll();
        console.log(data);
    });
}

But as the log shows, the column with the associated value is not being fetched:

Annotation-2020_2D00_05_2D00_22-090928.jpg

I know that I could fetch the data using REST, but since the data is already being shown in the subgrid, it must be a way to access it without sending another request.

I'm also trying to avoid unsupported solutions, but they are welcome if there's no supported way of doing that.

Any ideas?

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Cassio,

    Could you share more details about "but in my case, the column comes from a level below (linked to the related entity)"?

    As per my understanding, we could only get listed columns in subgrid.

    Please add a new column if you would like to get more field from related entity.

    Regards,

    Clofly

  • cmilanelo Profile Picture
    15 on at

    Hi Clofly Mao,

    I just edited my original post with a full example.

    Thank you

  • cloflyMao Profile Picture
    25,210 on at

    Hi Cassio,

    It seems that "rowData.getEntity().attributes" will only return fields of primary entity, even if attributes of related entity are actually included in fetchXml parameter.

    I didn't find any note which talks about the limitation after I have searched all methods and attributes of grid control from doc and many previous threads and blog articles.

    In a word, it could be by design, you might still need a REST call to get related entity data to meet your requirement.

    Regards,

    Clofly

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 107 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 92

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans