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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans