For those familiar with SharePoint document libraries and OneDrive for Business, there is a button that I think you’ll find quite useful: meet the OneDrive “Sync” button.
Sync will let you sync the current library to your OneDrive. I was recently asked to add the sync functionality to a page for a custom SharePoint application that we built. The idea was to allow the end users to stay on the application page without having to struggle to find the “Sync” button within the nested document libraries.
To do this, we had to refer to the documentation provided by Microsoft:
Basically, you can create a simple anchor HTML link that will open a site following this format:
odopen://sync/?siteId=SiteID_HERE&webId=WebID_HERE&listId=ListID_HERE&userEmail=UserEmail_HERE&webUrl=WebURL_HERE"
Developers will see that most of the information needed is in the _spPageContextInfo object that gets generated on every SharePoint page. For those non-devs curious about how they might find the necessary information to go this route, I have created a standalone page available on GitHub and I’ve provided the step-by-step guide below.
Fill in the site url, select the library to share, and enter an email.
Select a document library from the dropdown.
Click or Copy the generated link