1
votes

For Microsoft CRM 2013 is there any way to get the current view ID? It seems from my research the solution in CRM 2011 no longer works in CRM 2013. (or 2015)

The idea is execute a JavaScript code from a custom command bar ribbon button that executes over all records in the current homepage grid of an entity (or even a sub-grid).

Either by grabbing the current view ID or the FetchXML of a grid would work.

Alternatively, a custom entity that has a lookup to all views for a specific (With its own lookup to a custom entity that populates a view name when it is created/updated/deleted on a specific entity via a plugin) Which I haven't found a way possible yet.

2

2 Answers

1
votes

With Ribbon buttons you can pass the IDs from the grid using CrmParameter: https://msdn.microsoft.com/en-us/library/gg309332.aspx

SelectedControlSelectedItemIds - A string array of GUIDs for all selected items in a grid.

SelectedControlAllItemIds - A string array providing the GUIDs for all items displayed in a grid.

SelectedControlUnselectedItemIds - A string array of GUIDs for all unselected items in a grid.

0
votes

You should be able to get the id of the current view through this line of code:

var currentViewId = $('.ms-crm-View-Name:visible[currentview]').attr('currentview')

But be warned, it is a hack, and may break from one version/update to the next