Ribbon debug/Command checker tool

Image
Background: Usually when something goes wrong in the button visibility or to find out the rules, actions(js) being used in the ribbon button, we go and find either in the ribbondiffxml or through ribbon workbench. This is a time taking process.  Solution: Now there is a built-in tool called 'Command Checker' available. Using this tool, we can easily troubleshoot the button visibility related issues in home page grid, entity form, sub grid and global command bar as well.  To use/enable this tool, pass "ribbondebug=true" parameter in the url. Example, if you want to troubleshoot some button in Account form, below is the url,  https://trial.crm5.dynamics.com/main.aspx?appid=4db5bcb8-675b-ec11-8f8f-002248599a15&pagetype=entityrecord&etn=account&id=83883308-7ad5-ea11-a813-000d3a33f3b4 &ribbondebug=true This will enable the command bar in 3 places. 1. In the header's right side 2. In the Form command bar 3. If the form has any sub grids. Co...

Show/Hide ribbon button based on the selected view in the D365 subgrid

Requirement:

We had a requirement where we need to create custom button for 'Add Existing' functionality and show/hide this button based on the view selected in the Order subgrid.

Solution:

In the enable rule of the button, register a custom JS function and pass 'selected control' crm parameter to the function as shown below.





Below is the code snippet to retrieve the view name from the subgrid view.

 selectedControl.getViewSelector().getCurrentView().name  

With this you can compare the view name which you want and return true/false based on the selected view.

Complete function:

 function ShowHideCustomAddExistingOrderSubgrid(selectedControl) {  
   var enable = false;  
   if (selectedControl !== null  
     && selectedControl.getEntityName() === "salesorder"  
     && selectedControl.getViewSelector().getCurrentView() !== null) {  
     var viewName = "Orders in reschedule queue";  
     if (selectedControl.getViewSelector().getCurrentView().name === viewName) {  
       enable = true;  
     }  
     else {  
       enable = false;  
     }  
   }  
   else {  
     enable = false;  
   }  
   return enable;  
 };  



Comments

Popular posts from this blog

Convert datetime to user local in D365 Plugins

Ribbon debug/Command checker tool