Skip to main content

Notifications

Microsoft Dynamics CRM forum
Answered

javascript get selected row recordid

editSubscribe (0) ShareShare
ReportReport
Posted on by 2,397

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

  • Verified answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,039 on at
    RE: javascript get selected row recordid

    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

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: javascript get selected row recordid

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

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,039 on at
    RE: javascript get selected row recordid

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

  • Suggested answer
    meenoo Profile Picture
    meenoo 7,314 on at
    RE: javascript get selected row recordid

    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.

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,375 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans