Custom Script in SharePoint Online Revisited

The PnP community has become a valuable resource for documentation, sample code, and overall collaboration for all things Microsoft. If you've worked with Office/Microsoft 365, odds are that you've bumped into at least one community-driven component. Here are a few examples: Modern Script Editor SPFx web part that allows the embedding custom html/js/css into a modern page. PnP Modern Search Set of web parts that allow a more customized search experience, which fills some of the gaps left by the highlighted content out-of-the-box web part. Additional background here . Custom list view header One of the many example json styles for customizing content rendering in SharePoint. In this case, it sets a static, customized header instead of the default view header. List formatting has many samples to showcase different customization options. In the meantime, Microsoft is on track to add a few new things, while shutting down a few others. Microsoft has announced deprecations for older

Enabling 'View in File Explorer' in Office 365

 Office 365 has a new method to open libraries in Windows Explorer. Although Microsoft makes it clear that OneDrive should be the preferred way to access online content going forward (in tandem with files on demand feature to avoid using storage space), the open with explorer option, now called "View in File Explorer" is still an option. To enable this option fully, without issues, there are a number of steps that should be performed. Enable the option at the tenant level To enable the option to open a library with explorer, we need to have tenant rights and run the following commands : Connect-SPOService -Url Set-SPOTenant -ViewInFileExplorerEnabled $True Push the registry key to allow the action Unlike in previous iterations, the open with explorer option is only available in the browser Edge from Microsoft and even then it is only usable (even though it can be visible) if a certain key is installed . Enable the ConfigureViewInFileExplo

Breaking down document locking in SharePoint

This is a topic I've been meaning to discuss in a while. We open, change and close documents almost every day, and sometimes we collaborate with other people at the same time on those documents. SharePoint brings all co-authoring features we need, straight out-of-the-box, but sometimes, there are problems. While things are starting to look better on the cloud side, the concept of document locking is still very much up-to-date and understanding how it works and what to do when things go wrong is crucial. In an article that has since disappeared the Microsoft Knowledge Base (but still available here ), Microsoft explains it best: When a document is opened by a client program, Windows SharePoint Services puts a write lock on the document on the server. The write lock times out after 10 minutes. Users cannot modify the document during the time when the document is locked. In a scenario where the program that opens the document unexpectedly quits or crashes and you try to open the do

Programatically uncheck the option to remove personal information

Problem Office documents have a setting to remove personal information each time the document is saved. If you have track changes and people commenting for example, their names get removed and replaced by a generic "Author" name. This is sort of a security setting that it's nice to have, most in most cases it gets enabled unintentionally when using the Document Inspector to clean-up documents. While we can simply open up the trust settings and disable this, there might be times when we need to go over a substantial amount of documents and manual work is no longer effective. At the same time, this is a good proof of concept should we want to start automating other things on Office documents. While OpenXML seems to be a clear successor, the Interop Objects still allows us today to interact and manipulate Word documents, in writable Visual Studio C# applications. Where we can do something as easy as doc.RemovePersonalInformation = false Solution

Harmful warning when copying/moving between webdav sites and libraries

Problem Sometimes, when copying or moving documents between mapped libraries in SharePoint (whether they are network drives or just opened temporarily) we get the Windows Security warning: "These files might be harmful to your computer". This message is specially strange since the site already belongs to the Local Intranet Zone . Solution What we need to do is add the path "\\your-sharepoint-site" to the local intranet zone, save and log off and re-sign in. Internally, this change will add a file entry to the zones in the registry. Therefore, a way to perform this trough a .reg file, is: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\\*.subdomain] "http"=dword:00000001 "https"=dword:00000001 "file"=dword:00000001 After adding this key and signing off or restarting, the warning no longer appears.

Open Office documents in any browser using Office URI scheme

Problem: One of the problems when shifting to a non-IE browser in SharePoint, is that immediately documents start downloading instead of opening in the browser. While we can overcome that by tweaking the "Open in browser" library option, sometimes it is just very difficult to interact with Office since we cannot call "CoreInvoke" or functions such as createNewDocumentWithProgIDEx from the SharePoint OpenDocuments Class (OWSSUPP.DLL), often ending up with error message, The document could not be opened for editing. A Microsoft SharePoint Foundation compatible application could not be found to edit the document. One possible scenario could be: How to open an instance of a .dotx Word Document Template in Google Chrome and allow a suggested save location? Solution: Starting SharePoint 2013 and Office 2010 SP2, we can use URI schemes, which are basically URLs starting with "ms-X" which trigger the desktop application to open, and works in both IE and

Document ID not being generated

Problem In a scenario where we have many document Content Types, we may want to enable Document ID - aka "Permanent Links" - which is a feature in SharePoint that assigns a specific ID for each document. That ID never changes even if the document is renamed or moved to another location. In this scenario, the Document ID field was being generated for some libraries/content types, but not others, which is a surprisingly common problem. Background There are several stages we need to go through to enable use this mechanism. Stage 1 We enable the feature in the Site Collection Features. Stage 2 Under Site Collection Administration > Document ID Settings, we need to enable the assignment and pick a prefix. The IDs use the format: PREFIX-LISTID-LISTITEMID ( ref ) Where: PREFIX: the preconfigured prefix for the site collection, which can be any set of numbers and letters between 4-12 characters LISTID: the property docid_msft_hier_listid of the list

SharePoint Designer | JavaScript changes causing SPD to hang

Problem: Recently I started to notice that SharePoint Designer has been behaving strangely. When we click save on a JS file it goes on an eternal quest to try and save it The simple opening of an .aspx file that contains javascript functions will take minutes and fail with " The server could not complete your request. For more specific information, click the Details button. " After it gives up, the error is displayed: " The server unexpectedly closed the connection. " After this (and if you have pending changes) the Designer will prompt to save the file to an alternate location, but not before throwing yet another error: " Could not find a Web server at 'SiteUrl'. Please check to make sure that the Web server name is valid and your proxy settings are set correctly. If you are sure that everything is correct, the Web server may be temporarily out of service. " Solution: It seems that some file contents sort of get blocke

SharePoint and the magic of query strings

One of typical requests from users is the ability to have a page open in a certain state, where things automagically appear and happen by themselves. Throughout my travels, I have come by many of these magic strings of text that we put into the url bar and something amazing happens, some of these not even accessible - at least easily - through the user interface. My goal with this post is to lay down some of these bad boys, who they are and what they do. Old but gold, open the "Web Part Page Maintenance" Query: ?contents=1 Result: opens a page with all the web part instances, effectively allowing us to manage (close, delete, etc.) web parts and very useful to troubleshoot problematic web parts Go into the current page's edit mode If - for whatever reason - you need to open a page in edit mode, you can add this one. Query: ?ToolPaneView=2 Result: page opens automatically in edit mode Open a view in quick edit mode We can open up a view already in qui

Solved co-authoring failure for Office 2016 users causing locked documents

Problem: Users keep getting locked out of a document. A user is able to make changes, but then everyone else isn't. Among the errors: "We're having trouble connecting to the server. If this keeps happening, contact your help desk." "Upload failed. This file is locked for editing by ..." Fiddler displays a 404 cobalt error: Solution: Apparently, there is a key in the registry that if non-existent, will prevent co-authoring! There is a hotfix, the  October 13, 2015, update for Office 2016 (KB2920679) . Or simply add the following registry key, and then restart Word: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Common\FileIO] "EnableRealtimeChannel"=dword:00000000 (this could be saved as a .reg and executed) Source:

Easily access linked files in Word/Office

Problem: With the constant changes in the Office User Interface, it's gets increasingly difficult to find things. One feature that I am particularly annoyed about is the linked files. Whenever a user has a document with links to external documents, I never seem to find how to manage them. Solution: As usual, the complete list of commands comes to the rescue. Simply by going to File > Options > Quick Access Toolbar, we can see a list with commands, and if we pick "All commands", we will now find " Edit Links to Files " and bring it to the right for a quick shortcut on the top left.

Enable SharePoint Designer & code snippets in Office 365

I recently had to setup a new Office 365 tenant. One of the first things I noticed was that SharePoint Designer was disabled, and could not find an option anywhere to enabled it. Another problem caused by this is trying to add code snippets to pages, ending up with the message: "This HTML cannot be inserted because you don't have access to add scriptable Web Parts in this site. Please contact your administrator if you think you should have rights to do so." After searching for a while I found a solution using SPO . 1. Download and install SharePoint Online Management Shell 2. Load up the newly installed SharePoint Online Management Shell console 3. Run the following code snippet (after setting up your tenant details)