5

I have a SharePoint Online environment as https:///domain.sharepoint.com.

Now I am trying to add custom JS codes to the site page in the above specified site. Whenever I try to add the code on top level root site it always throws error:

Access denied. You do not have permission to perform this action or access this resource.

FYI: I am the owner of the tenant.

Also when I tried opening top level root site using SPD, there also I got the same error.

So, I want to know whether its possible to add some custom codes on the top level root site collection?

If its possible then how we can achieve this?

  • 1
    Have you enabled custom scripts from tenant level settings ? – Gautam Sheth Jul 24 '17 at 11:56
  • 1
    I just tried by enabling it still same error – Aakash Maurya Jul 24 '17 at 12:08
  • Can you add your account explicitly as the site collection admin and then check ? – Gautam Sheth Jul 24 '17 at 12:14
  • 1
    I am already member in site collection administrator .... – Aakash Maurya Jul 24 '17 at 12:18
  • I have the same issue... any resolution to this? – Michal Hainc Jul 2 '18 at 9:12
1

Go to SharePoint online admin center > Settings.

In the custom scripts section, ensure that you have turned on the scripting capabilities as below:

enter image description here

Once this is done, click on Save at the bottom.

Now, open SharePoint online PowerShell and run the below command(use the SharePoint admin account) :

Set-SPOSite "https://domain.sharepoint.com" -DenyAddAndCustomizePages 0

Now, you should be able to add custom scripts/user custom actions in your site collection.

By default, in a new tenant:

  1. For personal sites, custom scripting is disabled by default.
  2. For self-service created sites, custom scripting is disabled by default.
  3. For the Root Site Collection of the Tenant, custom scripting is disabled by default.

By changing the above setting and running the Powershell command, we will enable the scripts for the root site as well.

  • Get back to you on this as soon as I am done with trying.. – Aakash Maurya Jul 24 '17 at 12:59
  • Any luck ? Once you have changed the tenant level settings from admin center UI, it takes 24 hours to get reflected. But if you ran the powershell, it will be reflected immediately. – Gautam Sheth Jul 25 '17 at 6:30
  • I have the same acess denied problem with site collection admin trying to create user custom actions... your answer didn't help, but thanks for the effort anyway, any other ideas? – Michal Hainc Jul 2 '18 at 9:11
  • @MichalHainc - can you try it as Set-SPOSite "https://domain.sharepoint.com" -DenyAddAndCustomizePages $false ? – Gautam Sheth Jul 2 '18 at 16:33
  • I did it via powershell, user has the permission but still access denied – Michal Hainc Jul 2 '18 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.