Using CRM 2015.
I'm creating a button that loops over the selected records in a view and performs a custom method.
Here's the setup:
Created a button on the main view menu bar in one of our custom entities.
Added javascript for the new button to call.
try {
var selectedEntityReferences = [];
var selectedRows = Xrm.Page.getControl("<control name here>").getGrid().getSelectedRows();
alert("selectedRows:" + selectedRows.getLength());
selectedRows.forEach(function (selectedRow, i) {
selectedEntityReferences.push(selectedRow.getData().getEntity().getEntityReference());
alert(selectedRow.getData().getEntity().id);
});
} catch (ee) {
alert(ee.message);
}
I tried replacing "<control name here>" with what I thought the name of the control was - but it gives 'selectedRows is null' error.
This sent me on a search to find the proper control name.
In the MSD documentation I found 'Xrm.Page.getControl()' should return a list of controls - but when I use this method it returns a null object.
This leads me to believe there are no controls on the page - but how is this possible?
Also - where would I find the proper name for the control that holds the view grid?
*This post is locked for comments