Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

getting list of records in a subgrid using javascript

Posted on by 345

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

  • svignesh Profile Picture
    svignesh 345 on at
    RE: getting list of records in a subgrid using javascript

    Hello Jason,

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

  • Jason M. Cosman Profile Picture
    Jason M. Cosman 5,234 on at
    RE: getting list of records in a subgrid using javascript

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

  • svignesh Profile Picture
    svignesh 345 on at
    RE: getting list of records in a subgrid using javascript

    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

  • Suggested answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: getting list of records in a subgrid using javascript

    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

  • Verified answer
    Jason M. Cosman Profile Picture
    Jason M. Cosman 5,234 on at
    RE: getting list of records in a subgrid using javascript

    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.

  • svignesh Profile Picture
    svignesh 345 on at
    RE: getting list of records in a subgrid using javascript

    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

  • Jason M. Cosman Profile Picture
    Jason M. Cosman 5,234 on at
    RE: getting list of records in a subgrid using javascript

    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!

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans