Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Xrm.Page.getControl("crmGrid") returns null when select all

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a custom js file which finds the selected rows from Editable grid. 

Xrm.Page.getControl("crmGrid") returns null once after i click select All checkbox on the Editable grid.

But the same code returns the grid object if i select any individual item from the editable grid.

Any suggestions or thoughts would be much appreciated. 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm.Page.getControl("crmGrid") returns null when select all

    This code will trigger when clicking Add to Marketing list command

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.Page.getControl("crmGrid") returns null when select all

    Hi Senthil,

    Your code is correct but can you please tell me in which event you attach the JS function ? 

    If you attach your function in OnRecordSelect event then  this function will fire when the user moves across rows in the grid. This will not fire if you select multiple rows from the grid.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm.Page.getControl("crmGrid") returns null when select all

    if (Xrm && Xrm.Page.getControl("crmGrid") != null && Xrm.Page.getControl("crmGrid").getGrid().getSelectedRows() != null) {

           var myRows= Xrm.Page.getControl("crmGrid").getGrid().getSelectedRows();

           selectedRow.forEach(function (row, rowIndex) {

               myList.push(row.getData().getEntity().getKey());

           });

    This above code doesn't work if you check "Select All" in Editable Grid of any entity.

    But if you select any one row and then check "Select All", it works. The root cause is Xrm.Page.getControl("crmGrid") is null after u press "Select All".

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.Page.getControl("crmGrid") returns null when select all

    Hi ,

    when you are triggering the function? Can you please share your complete code ?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans