Enable custom script on modern SharePoint sites to recover your favourite functionalities
Let me start with a HUGE disclaimer: even though it is possible to enable custom scripts on modern SharePoint, you should only consider using it when there is no other alternative.
Having custom script disabled by default on SharePoint removes functionalities that old school users miss, such as list templates and the solution gallery,among several others. Most of the features removed by custom scripts can be achieved using PnP and SharePoint Online Cmdlets.
If you need to bring back any of the functionalities listed below you will need to follow the steps described in the article below:
|Save Site as Template||No longer available in Site Settings||Users can still build sites from templates created before custom script was blocked.|
|Save document library as template||No longer available in Library Settings||Users can still build document libraries from templates created before custom script was blocked.|
|Solution Gallery||No longer available in Site Settings||Users can still use solutions created before custom script was blocked.|
|Theme Gallery||No longer available in Site Settings||Users can still use themes created before custom script was blocked.|
|Help Settings||No longer available in Site Settings||Users can still access help file collections available before custom script was blocked.|
|HTML Field Security||No longer available in Library Settings||Users can still use HTML field security that they set up before custom script was blocked.|
|Sandbox solutions||Solution Gallery is no longer available in Site Settings||Users can’t add, manage, or upgrade sandbox solutions. They can still run sandbox solutions that were deployed before custom script was blocked.|
|SharePoint Designer||Pages that are not HTML can no longer be updated.
Handling List: Create Form and Custom Action will no longer work.
Subsites: New Subsite and Delete Site redirect to the Site Settings page in the browser.
Data Sources: Properties button is no longer available.
|Users can still open data sources.|
|Uploading files that potentially include script||The following file types can no longer be uploaded to a library
|Existing files in the library are not impacted.|
Before getting custom script running on your modern site, you need to make sure it is already enabled at tenant level. To verify or enable it, you should follow these steps:
- From your SharePoint site, click on the waffle icon
- Click on Admin
- Expand Admin centers and click on SharePoint
- On the SharePoint Admin Center click on Settings
- Scroll down and locate the Custom Script
- Click on Allow users to run custom script on personal sites
- Click on Allow users to run custom script on self-service created sites
- Click OK
Note: Changes to the tenant settings can take up to 24 hours to be applied.
To enable custom scripts on modern sites, you will need to use SharePoint Online Cmdlets. If you don’t have it installed download it from here.
- Open the PowerShell console
- Execute the command
Connect-SPOService -Url https://tenant-admin.sharepoint.com
- Execute the command bellow with the url for the modern site collection
Set-SPOSite -Identity https://tenant.sharepoint.com/sites/contoso -DenyAddAndCustomizePages 0
Don’t enable custom scripts unless it’s your last option, having custom scripts enabled can put your tenant at risk.