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)

javascript get selected row recordid

(0) ShareShare
ReportReport
Posted on by 2,512

Hi, I am trying to get the contact id from a selected row, like the below, how can I get that?

2018_2D00_06_2D00_11_5F00_1649.png

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    meenoo Profile Picture
    7,316 on at

    Hi sdnd,

    Please refer this below snippet:

    var selectedRows = Xrm.Page.getControl("States").getGrid().getSelectedRows();

       selectedRows.forEach(function (selectedRow, i) {

           var s = selectedRow.getData().getEntity().getEntityReference();

            var selectedRowGuid=s.id;

           var selectedRowName=s.name;

           var selectedRowEntityName=s.entityType;

       });

    The above code snippets returns collection of selected rows and by iterating the collection we can retrieve the properties like

    ·         id - Here id is nothing but Guid of record

    ·         name - Here name will return the value in name fields

    ·         entityType - This will return the logical name entity which is displaying as SubGrid

    Thank you.

  • Mahendar Pal Profile Picture
    45,095 on at

    You can refer this as well: msdn.microsoft.com/.../dn932126.aspx

  • sdnd2000 Profile Picture
    2,512 on at

    Hi, it is working fine with subgrid, what if it is the default system view in contact page?

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Assuming you are referring Home page then it will be a different way, you can have a ribbon button, which can read record from the selected record, you need to use CrmParameter (msdn.microsoft.com/.../gg309332.aspx), and if you want sample code check this one step by step:

    crmhub.blogspot.com/.../how-to-get-selected-records-guid-from-home-page-entity-view-using-Java-Script-MS-Dynamic-CRM.html

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans