How to enable Content Editor and Script Editor web parts in SharePoint Online?

Although Microsoft recommends to adopt the new technology and customize the SharePoint Online portals through SharePoint Framework, we often come to face the customer's requirement where the customizations go far beyond the out of the box layout and demands something which is not available in Modern pages and layouts. In those scenarios, we have to go back to the classic approach and use the client side scripts and web parts to achieve the functionality.

Content Editor and Script Editor web parts were such a blessing during the SharePoint on-premises days and we would love to have them back in SharePoint Online which is currently not available by default. To enable these two champions, there are two ways.

Method 1:


You can also directly access the Tenant Settings page directly from the browser by accessing the below URL:

https://sharepointerguy-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx

In this page, if you will navigate to the Custom Script section, then you will see by default the below options will be selected:

Prevent users from running custom script on personal sites
Prevent users from running custom script on self-service created sites

Here change to the below options:

Allow users to run custom script on personal sites
Allow users to run custom script on self-service created sites




Note: This may take up to 24 hours to reflect the changes. Sometimes it may take more than that and sometimes it may take 3/4 hours also.

Once the custom script is enabled in the Office 365 tenant. You will be able to see the script editor web part and content editor web part.

Method 2:

In some cases, the above method could not work. In that case, the below PowerShell commands should serve the purpose. (You need SharePoint Online Management Shell to run these commands)

$username="Zeeshan@sharepointerguy.onmicrosoft.com"
$userCredential = Get-Credential -UserName $username -Message "*yourpassword"
Connect-SPOService -Url https://sharepointerguy-admin.sharepoint.com -Credential $userCredential
Set-SPOsite https://sharepointerguy.sharepoint.com/sites/ZeeTeamSite -DenyAddAndCustomizePages 0


This method should instant enable both of the web parts in the site.

Things you must know:

  • If you are using a SharePoint Online modern team site, then the script editor web part or content editor web part will not appear.
  • Microsoft is not recommending to use script or content editor web parts, you should use the SharePoint framework development (SPFx).
  • We can not add script editor web part inside a modern SharePoint page.

Thanks to Bijay Kumar for writing on these excellent ways to enable these web parts.

Comments

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

SharePoint online hub navigation not updating for other users