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 :
Microsoft Dynamics CRM (Archived)

getting list of records in a subgrid using javascript

(0) ShareShare
ReportReport
Posted on by 347

I want to get list of all records that are in a subgrid

Is there a way to get it using some api call or using javascript?

I don't want to have the subgrid and then hide it in the page where I am going to fetch these records, I have tried selected rows and get, but that is not what I need



var selectedRows = Xrm.Page.getControl("Contacts").getGrid().getSelectedRows();
var rows = Xrm.Page.getControl("Contacts").getGrid().getRows();

*This post is locked for comments

I have the same question (0)
  • Jason M. Cosman Profile Picture
    5,234 Moderator on at

    Hello Vicky;

    What are you going to do with this listing of records in the sub grid? Is this subgrid showing a 1:M or M:M relationship? It would be just as easy to do a FetchXML or WebAPI call for these records instead of interrogating the subgrid for its results. Looking into the sub grid might not be the best as you need to ensure it's properly loaded its date.

    In your logic if I understand correctly you want to be able to hide the subgrid but still get it's rows? If this is the case then get selected rows deffinetly isn't going to work as it will be hidden with no selected rows. In terms of the getRows call below it; are you sure your subgrid is called "Contacts"?

    Let me know what you think!

  • svignesh Profile Picture
    347 on at

    Hello Jason,

    I have a children subgrid and a Parent subgrid in the case entity

    There will be some goals that will be added for a case, in the Goal I want to show the list of parents in the subgrid as an autocomplete field to specify the parent(parent list who are in that particular case) for whom the goal is for

  • Verified answer
    Jason M. Cosman Profile Picture
    5,234 Moderator on at

    Hello Vicky;

    Ok cool; so you are looking at a 1:M relationship with multiple parents for this one account. I'd definitely recommend going to get the data from that relationship instead of pulling it from the subgrid. You should be able to do a fetchxml or webapi call for the data.

  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi Vicky,

    I'm not sure what your end goal is. Are you trying to get the data from the grid, or run a query so you don't need to rely on the grid?

    getRows will give you back all the rows in the grid, and you can call row.getData().getEntity() to get the record represented by the row.

    If you want to query via javascript, you can using the specs here: msdn.microsoft.com/.../gg985387.aspx

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • svignesh Profile Picture
    347 on at

    Hello Jason,

    Not able to delete the post, found out there was a typo in the name, kindly ignore

    How can I select the data in the subgrid using webapi?

    I tried

    localhost/.../new_medicalCase(687615e4-3e05-e611-9419-000d3a1045a2)$expand=FamilyMembers($select%20=%20new_name)

    and got this error

    {

     "error":{

       "code":"","message":"Could not find a property named 'FamilyMembers'

    Not able to delete the post, found out there was a typo in the name

  • Jason M. Cosman Profile Picture
    5,234 Moderator on at

    So your original code worked just a typing mistake? That's wonderful news great job!

  • svignesh Profile Picture
    347 on at

    Hello Jason,

    Not the original post, I meant the last reply post with webapi link :) 

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans