Personalize SharePoint command bar with Json
/ 2 min read
Table of Contents
The problem
In many companies data must be managed only through a specific process (for example via custom PowerAutomate flow) and allowing users, for example, to ๐ณ๐ฟ๐ฒ๐ฒ๐น๐ create items in a list can ๐ฒ๐ฎ๐๐ถ๐น๐ ๐ฏ๐ฟ๐ฒ๐ฎ๐ธ ๐๐ต๐ฎ๐ ๐ฝ๐ฟ๐ผ๐ฐ๐ฒ๐๐.
What to do?
You can manage this scenario with complex solutions, sure, but I think sometimes small declarative customizations can significantly improve governance and user behavior without complexity.
In this case with SharePoint you can easily: โข Hide specific commands โข Change the label of a command โข Reorder commands in the bar โข And more
๐ Here the Microsoft documentation: https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/view-commandbar-formatting
How to?
Below an example of how to hides the โ๐ก๐ฒ๐โ, โ๐๐ฑ๐ถ๐ ๐ถ๐ป ๐ด๐ฟ๐ถ๐ฑ ๐๐ถ๐ฒ๐โ, and โ๐ฆ๐ต๐ฎ๐ฟ๐ฒโ commands in a SharePoint list by formatting a specific view (for example, the โAll Itemsโ view).
{ "commandBarProps": { "commands": [ { "key": "new", "hide": true }, { "key": "editInGridView", "hide": true }, { "key": "share", "hide": true } ] }}Conclusion
๐ง๐ต๐ถ๐ ๐ถ๐ ๐ผ๐ป๐น๐ ๐ฎ ๐๐๐ฒ๐ฟ ๐ถ๐ป๐๐ฒ๐ฟ๐ณ๐ฎ๐ฐ๐ฒ ๐ฐ๐๐๐๐ผ๐บ๐ถ๐๐ฎ๐๐ถ๐ผ๐ป. Ensure that users do not have permissions to create custom views as they could otherwise bypass these UI restrictions. In a document library context, for example, hiding the โNewโ button does not fully prevent file creation since users can still add files via drag & drop.
In a SharePoint list context where drag & drop is not supported this approach becomes a ๐น๐ผ๐-๐ฐ๐ผ๐๐, ๐น๐ผ๐-๐ถ๐บ๐ฝ๐ฎ๐ฐ๐, ๐ต๐ถ๐ด๐ต-๐๐ฎ๐น๐๐ฒ solution.