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?

  • cloflyMao Profile Picture
    25,208 on at
    RE: Getting related data shown in subgrid with JavaScript

    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

  • cmilanelo Profile Picture
    15 on at
    RE: Getting related data shown in subgrid with JavaScript

    Hi Clofly Mao,

    I just edited my original post with a full example.

    Thank you

  • cloflyMao Profile Picture
    25,208 on at
    RE: Getting related data shown in subgrid with JavaScript

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 97

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans