You already know the GUID of a view, nothing surprising. But, you want to get what current view is active. Because at times, you want to compare and return values to a CustomRule based on what view is being set currently!
Let’s take a look!
Passing Parameter to JS function in Ribbon Workbench
Let’s assume the below scenario –
- You have a Ribbon button on the Account entity. And it looks like below.
- So here’s what you pass to the function that this button will call. No matter where that function is being called i.e. on Press of the button in Command or as a Custom Rule in an Enable Rule. You can pass this parameter called as PrimaryControl (If you are calling your function on selection of a record, you can even use SelectedControl and continue as is)
Reading GUID of the current view in Browser’s Dev Console
Now, let’s say you have a button on the selection of a Row or even on press of the button itself and it calls the function to which you’ve already passed PrimaryControl, here’s how you read it –
- Notice that the argument is passed, set a debugger; so that you don’t have to manually set breakpoints.
- Now, go to Console, and check this variable in which PrimaryControl is being passed. You’ll notice that _getCurrentView() is available for you
- Simply, select it in the function and press enter, you’ll see details inside.
- And you can simply read the id like you read an attribute.
Hope this helps!!
Here are some more Ribbon Workbench / JS / customization related posts you might want to look at –
- Pass Execution Context to JS Script function as a parameter from a Ribbon button in Dynamics 365 | Ribbon Workbench
- Pass selected rows’ GUIDs to ribbon button in D365 | Ribbon Workbench
- Debug Ribbon button customization using Command Checker in Dynamics 365 CE Unified Interface
- Show Ribbon button only on record selection in Dynamics CRM
- Hide Custom Ribbon Button [Easy Way] – Ribbon Workbench
- Enable Flow button on D365 Ribbon
- [SOLVED] Navigating URL from Ribbon’s custom button in Dynamics for Phones app
- Fix Ribbon icons on the Unified Interface in D365 CE
- Create a New Record button for Activity Type entity using Ribbon Workbench: D365
- D365 Ribbon Button shortcut to open a Document in SharePoint Online
Thank you!!