Hide Headers, Commandbar, Tabs in D365 Forms

Image
There are options available to hide Command Bar, Header part and Tabs.  Below is the screenshot which highlights these areas for your understandings. let formContext = Xrm.Page ; or let formContext = executionContext.getFormContext(); // Hide Header part formContext.ui.headerSection.setBodyVisible(false);   //Hide Command bar formContext.ui.headerSection.setCommandBarVisible(false);   // Hide Tabs formContext.ui.headerSection.setTabNavigatorVisible(false); After all are hidden,

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

Using Resx file in D365 Plugins/Workflows

Using Shared libraries in D365 CE Plugin