Skip to main content
added 1180 characters in body
Source Link
SP 2022
  • 4.2k
  • 4
  • 20
  • 45

In the modern SharePoint online page - adding script editor web part is not recommended. We can add the script editor web part using the SPFx web part. In the GitHub, there is a modern script editor web part which we can install for the same purpose.

1: Clone or Download the repo:

You will have to clone this repo: https://github.com/SharePoint/sp-dev-fx-webparts or Directly download it from here: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor

  1. Edit the Write-manifests.json.

  2. Build the package

  3. Build the package and deploy

Demo Example:

Modern Script Editor Webpart

Source:

Add The Script Editor Web part back to SharePoint Modern Experience

Script editor web part for SharePoint Modern pages.

How to enable script editor web part in SharePoint online classic page?

First, enable the custom scripting from the admin center by following the below the navigation, then need to execute the PowerShell script - I had also faced this but with the combination of these two - got it fixed.

Go to your tenant setting page thru this URL

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

Note: Here “spend” is my tenant name, you need to pass your tenant name.

Now see the “Custom Script” section by default both the radio button is selected as prevent – this is the default behavior and due to this script editor and content editor web part is missing from SharePoint online page.

Now select to allow users to run the custom script for both the radio button as like below:

Allow users from running custom script on personal sites. Allow users from running custom script on self-service created sites)

Allow Custom Script in SharePoint Online

This will not enable the custom script until we execute the below PowerShell Script.

$adminUserID=”youradminaccount@< sprnd.onmicrosoft.com >” $userCredential = Get-Credential -UserName $adminUserID -Message “Enter password” Connect-SPOService -Url https://sprnd-admin.sharepoint.com/ -Credential $userCredential Set-SPOsite “https://sprnd.sharepoint.com/sites/TestSite001″ -DenyAddAndCustomizePages 0 

Once, we execute the above PowerShell script, immediately script editor will be available.

For details refer to the below article:

SharePoint Online – O365: How to enable script editor web part in SharePoint online

First, enable the custom scripting from the admin center by following the below the navigation, then need to execute the PowerShell script - I had also faced this but with the combination of these two - got it fixed.

Go to your tenant setting page thru this URL

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

Note: Here “spend” is my tenant name, you need to pass your tenant name.

Now see the “Custom Script” section by default both the radio button is selected as prevent – this is the default behavior and due to this script editor and content editor web part is missing from SharePoint online page.

Now select to allow users to run the custom script for both the radio button as like below:

Allow users from running custom script on personal sites. Allow users from running custom script on self-service created sites)

Allow Custom Script in SharePoint Online

This will not enable the custom script until we execute the below PowerShell Script.

$adminUserID=”youradminaccount@< sprnd.onmicrosoft.com >” $userCredential = Get-Credential -UserName $adminUserID -Message “Enter password” Connect-SPOService -Url https://sprnd-admin.sharepoint.com/ -Credential $userCredential Set-SPOsite “https://sprnd.sharepoint.com/sites/TestSite001″ -DenyAddAndCustomizePages 0 

Once, we execute the above PowerShell script, immediately script editor will be available.

For details refer to the below article:

SharePoint Online – O365: How to enable script editor web part in SharePoint online

In the modern SharePoint online page - adding script editor web part is not recommended. We can add the script editor web part using the SPFx web part. In the GitHub, there is a modern script editor web part which we can install for the same purpose.

1: Clone or Download the repo:

You will have to clone this repo: https://github.com/SharePoint/sp-dev-fx-webparts or Directly download it from here: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor

  1. Edit the Write-manifests.json.

  2. Build the package

  3. Build the package and deploy

Demo Example:

Modern Script Editor Webpart

Source:

Add The Script Editor Web part back to SharePoint Modern Experience

Script editor web part for SharePoint Modern pages.

How to enable script editor web part in SharePoint online classic page?

First, enable the custom scripting from the admin center by following the below the navigation, then need to execute the PowerShell script - I had also faced this but with the combination of these two - got it fixed.

Go to your tenant setting page thru this URL

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

Note: Here “spend” is my tenant name, you need to pass your tenant name.

Now see the “Custom Script” section by default both the radio button is selected as prevent – this is the default behavior and due to this script editor and content editor web part is missing from SharePoint online page.

Now select to allow users to run the custom script for both the radio button as like below:

Allow users from running custom script on personal sites. Allow users from running custom script on self-service created sites)

Allow Custom Script in SharePoint Online

This will not enable the custom script until we execute the below PowerShell Script.

$adminUserID=”youradminaccount@< sprnd.onmicrosoft.com >” $userCredential = Get-Credential -UserName $adminUserID -Message “Enter password” Connect-SPOService -Url https://sprnd-admin.sharepoint.com/ -Credential $userCredential Set-SPOsite “https://sprnd.sharepoint.com/sites/TestSite001″ -DenyAddAndCustomizePages 0 

Once, we execute the above PowerShell script, immediately script editor will be available.

For details refer to the below article:

SharePoint Online – O365: How to enable script editor web part in SharePoint online

Source Link
SP 2022
  • 4.2k
  • 4
  • 20
  • 45

First, enable the custom scripting from the admin center by following the below the navigation, then need to execute the PowerShell script - I had also faced this but with the combination of these two - got it fixed.

Go to your tenant setting page thru this URL

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

Note: Here “spend” is my tenant name, you need to pass your tenant name.

Now see the “Custom Script” section by default both the radio button is selected as prevent – this is the default behavior and due to this script editor and content editor web part is missing from SharePoint online page.

Now select to allow users to run the custom script for both the radio button as like below:

Allow users from running custom script on personal sites. Allow users from running custom script on self-service created sites)

Allow Custom Script in SharePoint Online

This will not enable the custom script until we execute the below PowerShell Script.

$adminUserID=”youradminaccount@< sprnd.onmicrosoft.com >” $userCredential = Get-Credential -UserName $adminUserID -Message “Enter password” Connect-SPOService -Url https://sprnd-admin.sharepoint.com/ -Credential $userCredential Set-SPOsite “https://sprnd.sharepoint.com/sites/TestSite001″ -DenyAddAndCustomizePages 0 

Once, we execute the above PowerShell script, immediately script editor will be available.

For details refer to the below article:

SharePoint Online – O365: How to enable script editor web part in SharePoint online