Office 365 – SharePoint Online – “Access Denied” error while uploading custom template for “Document” content type

Hi All,

Today new issue and solution πŸ™‚

Background: In one of our SharePoint Online project we have requirement to create the custom document template. So we created custom content type derived from OOB Document content type. Since this is one time activity we thought to do it simply from the UI.

We created our custom document template and saved it locally. We went to “Advanced Settings” of content type and try to upload the our custom template as

Fig 1 : Office 365 – SharePoint Online – Advance Settings of Document content type

NOTE: Account though which we logged in to our SharePoint online site is “Global Administrator” and “SiteCollection Administrator” .

As soon as we clicked on OK button we are redirected to “AccessDenied.aspx” page as

Access denied error while uploading custom document template for content type

Fig 2 : Office 365 – SharePoint Online – Access Denied error while uploading custom document template for content type

Solution: I was wondering the account using which we are logged in to the site has “Global Administrator” and “SiteCollection Administrator” rights and still “Access Denied” error πŸ™

After bit thinking and googling it seems to be issue with custom scripts. By default custom script disabled at tenant level as

Office 365 - SharePoint Online - Tenant Level Setting - Custom Script - By default disabled

Fig 3 : Office 365 – SharePoint Online – Tenant Level Setting – Custom Script – By default disabled

We need to enable the “custom script” feature for the site. We can enable custom script from “Settings” options from SharePoint admin center which affects whole tenant or at site level using PowerShell cmdlets.

There are security implications by enabling custom scripts. Must read article for the same – Security considerations of allowing custom script

But since we need to upload custom template, we will enable custom script for our given site using PowerShell cmdlet.

Following are the steps to enable the custom scripting using PowerShell script

  • Open “SharePoint Online Management Shell”
  • Connect to Office 365 using SharePoint admin URL as
PS C:\> Connect-SPOService

cmdlet Connect-SPOService at command pipeline position 1
Supply values for the following parameters:
Url: https://knowledgejunction-admin.sharepoint.com

  • Verify the default settings for your site once as
PS C:\> Get-SPOSite 
https://knowledgejunction.sharepoint.com/sites/config | fl
Title                                    : Configuration
AllowSelfServiceUpgrade                  : True
DenyAddAndCustomizePages                 : Enabled

  • From above script result, it seems “DenyAddAndCustomizePages” is enabled by default. We need to disable as
PS C:\> Set-SPOSite https://knowledgejunction.sharepoint.com/
sites/config -DenyAddAndCustomizePages 0

PS C:\> Get-SPOSite 
https://knowledgejunction.sharepoint.com/sites/config | fl
Title                                    : Configuration
AllowSelfServiceUpgrade                  : True
DenyAddAndCustomizePages                 : Disabled

Once we enabled custom script we are successfully upload the custom template for the content type πŸ™‚

Thanks for reading πŸ™‚

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles.

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.