CRM Crate

Hide & Show command bar using JavaScript in Dynamics 365.

We will learn to hide & show command bar using JavaScript in Dynamics 365. Before we start, make sure to subscribe to CRM Crate so that you stay up-to-date in field of Dynamics 365.

Hide & Show command bar using JavaScript in Dynamics 365.

What are command bars in Dynamics 365?

Microsoft Dynamics 365 displays commands or ribbons in different ways depending on the table and the client. In most places in the web application, you will see a command bar instead of a ribbon. Dynamics 365 for Tablets also uses data defined as ribbons to control what commands are available using a command bar that is optimized for touch.

The command bar provides better performance. The ribbon is still displayed in the web application for certain forms and it is still used for list views in Dynamics 365 for Outlook. Both the command bar and the ribbon use the same underlying XML data to define what commands to display, when the commands are enabled, and what the commands do.

Hide & Show command bar’s dynamically using JavaScript –

We will use the setCommandBarVisible client API reference to update the command bar’s visibility using JavaScript.

formContext.ui.headerSection.setCommandBarVisible(bool);

Sets the command bar visibility. This method is supported only on Unified Interface.

JavaScript snippet code for changing visibility of command bar –

The below JavaScript function has been triggered during the OnChange event of form’s field.

//CRM Crate - JavaScript Snippet
function CallMethod (executionContext) {
//Reading Attribute Value From The Form.
var formContext = executionContext.getFormContext();

var Input = formContext.getAttribute("cc_input").getValue();
if(Input == true)
{
formContext.ui.headerSection.setCommandBarVisible(false);
}
else{
formContext.ui.headerSection.setCommandBarVisible(true);
}
}

Validate the output in Dynamics 365 –

Once the above code is been configured and deployed, navigate to the Dynamics 365 form and verify whether the command bar’s visibility changes dynamically as shown below.

Thus we learned to hide & show the command bar using JavaScript in Dynamics 365.

5 1 vote
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!
0
Would love your thoughts, please comment.x
()
x

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.