How to hide command bar/ ribbon bar of a form in Model driven apps/ Dynamics 365

Hello everyone and welcome to my blog. In today’s blog, I will show you how to show/ hide the ribbon bar or command bar on a record form dynamically, in Dynamics 365/ Model Driven apps.

This is not a very common requirement but here I was having this requirement. The requirement was to hide the ribbon bar for a record completely when users with specific security role open the record.

Quite unknown to many, Model driven apps client script has API’s to do that. You can now access the header section of a form using the following code.

formContext.ui.headerSection

Once you get hold of the header section, there are multiple methods available to control the display of multiple components of the header. And one of them is the function setBodyVisible.

The function show/ hide the command bar or ribbon menu. Below is the code to do that.

formContext.ui.headerSection.setBodyVisible(false);

And below is the behavior of the form when I pass false to the function.

Trust me, if you are not aware of this API, it is a seemingly tough requirement to achieve.

Hope you liked this post. If this post has helped, you can buy me a coffee.

For similar topics on Microsoft.NET and Power Platform, subscribe to my blog using the Subscribe option on right pane.

Debajit Dutta
Business Solutions MVP


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading