1

I added a button on my subgrid named "lots_associes", and I want by clicking on this button javascript recover all selected records.

I tried all the solutions proposed as http://vikramxrm.blogspot.fr/2013/11/read-subgrid-records-ms-crm-2013-using.html

But it seems that the functions "getElementById ('lots_associes')" do not work while "Xrm.Page.ui.controls.get('lots_associes')" works. I have the good name of the grid.

Do you have any ideas?

1 Answers1

1

In 2011, it was the Ribbon's job: I assume 2013 would be the same (despite the different look'n'feel).

You had to use CrmParameter to have the IDs of the selected records:

// in the RibbonDiffXml
<JavaScriptFunction FunctionName="YourFunc" Library="YourLibrary">
    <CrmParameter Name="MyRecordIDs" Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>

//The corresponding function would look like
function YourFunc(recordIDs){
    // recordIDS will be filled with the IDs of the selected records
}

Here is the reference for CrmParameter (it says it applies to 2011 but there is no equivalent for 2013 so I believe this info is still valid)

On a side note, never use getElementById (it's not supported: no support from microsoft and any rollup might break your code).

Alex
  • 23,004
  • 4
  • 39
  • 73
  • Thank you for your answer. However this solution return all the records contain in the subgrid. My problem now is that I only want those selected manually. Any ideas? Thank you very much – user3374480 Mar 03 '14 at 18:38
  • I mis-copy-pasted the Value, now it's fixed. I also forgot to include the URL for the link... fixed that too. – Alex Mar 04 '14 at 10:30