SharePoint Online: JSON Formatting | Hide ‘Add shortcut to OneDrive’ Button


SharePoint Online [SPO] is a modern, cloud-based service accessible from any modern browser. Emphasis on modern service and modern browser. Still, because of many legacy business processes, end-users flock to sync their SPO files the first chance they get. They ultimately achieve the same purpose, but there are actually two ways they can sync their documents. From the library menu of options, they can choose to (1) Sync or (2) Add shortcut to OneDrive:

Figure 1 - SharePoint Online document library command bar.
Figure 1SharePoint Online document library command bar.

To block library syncing is easy enough. Anyone with elevated permissions to the document library can open the Library settings and choose to NOT allow items to be downloaded offline:

Figure 2 - SharePoint Online document library settings.
Figure 2SharePoint Online document library settings.

Not allowing items to be downloaded offline removes the Sync button from the menu:

Figure 3 - SharePoint Online document library command bar, Sync button removed.
Figure 3SharePoint Online document library command bar, Sync button removed.

Unfortunately, getting rid of the shortcut button isn’t as simple. Enabling or disabling this button is a tenant-wide setting, so it’s all or nothing. That is without using JSON to format the library view. Tweaking the menu, JSON can customize the command bar and hide this specific button:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "commandBarProps": {
    "commands": [
      {
        "key": "addShortcut",
        "hide": true
      }
    ]
  }
}

Now, with the JSON formatting applied, the Add shortcut to OneDrive button is hidden from everyone:

Figure 4 - SharePoint Online document library command bar. Add shortcut to OneDrive button removed.
Figure 4SharePoint Online document library command bar. Add shortcut to OneDrive button removed.

Conclusion:
JSON formatting is a quick win to tweak list and library menus without depending on CSS or JavaScript. No client-side scripting experience necessary…

“Rule-following, legal precedence, and political consistency are not more important than right, justice and plain common-sense.”

W. E. B. Du Bois

#BlackLivesMatter

2 thoughts on “SharePoint Online: JSON Formatting | Hide ‘Add shortcut to OneDrive’ Button

Leave a comment