SharePoint Script and Search web parts usage for members (errors, solution and PnP)

Posted 15 November 2017 12:00 AM by Ivan Chesa, Junior Developer @ ClearPeople

Recently, I had a problem when I wanted to create a page that had a script editor web part embedded ​in the layout (custom page layout).

When I was logged in as an owner user, I could create this kind of page without any problem. However, when I was logged in as a member user, I could create the page and check in the page but, I couldn’t publish the page or edit it again after that. When I tried to publish or edit after checking in I was getting this error:

sharepoint script

Besides, if I used again the owner user to edit the page, this time I could edit the page without error but, I noticed that the code snippet of the script editor web part was blank (the code disappeared).

After some research, I also noticed that when using a member user, I couldn’t add a search web part to any page (the set of search web parts is not available when editing a page) and I concluded that this was being caused due to a problem with the permissions of the built-in members group.

In order to avoid this behavior, you need to add a set of new permissions to the group that you want to be able to create this kind of custom pages.

To do this manually, follow these steps:

  • Log in as the site collection administrator
  • Go to “Site settings” and click on “Site permissions”
  • Click on “Permission Levels”:

Sharepoint script2

 

  • Click on “Add a Permission Level” to create a new set of permissions:

sharepoint script3

 

  • Give the new permission level a name, mark the “Add and Customize Pages” checkbox under the “Site Permissions” section (when clicking on the box, several permissions will be checked automatically) and click the “Create” button at the bottom of the page:

sharepoint script4

  • Go back to “Site permissions”, select the group that you want to have this new set of permissions and click on “Edit User Permissions”:

sharepoint script5


 

  • Check the box of the new set of permissions you’ve just created and click “OK”:

sharepoint script6



After following these steps, the users in that group will be able to create and publish custom pages with script editor web parts embedded in the layout and also to add search web parts to pages.

On the other hand, if you are using PnP in your development, you could perform all of these steps in one only xml template. In order to create this new permission level and assign it to the built-in members group of your site collection, you could use this xml template:

<?xml version="1.0" encoding="utf-8" ?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2016/05/ProvisioningSchema">
<pnp:Preferences/>
<pnp:Templates>
<pnp:ProvisioningTemplate ID="Root.Security">
<pnp:Security ClearSubscopes="false">
<pnp:Permissions>
<pnp:RoleDefinitions>
<pnp:RoleDefinition Name="Deploy Web Parts" Description="Can edit pages and add Search and Editor Web Parts.">
<pnp:Permissions>
<pnp:Permission>EmptyMask</pnp:Permission>
<pnp:Permission>ViewListItems</pnp:Permission>
<pnp:Permission>Open</pnp:Permission>
<pnp:Permission>ViewPages</pnp:Permission>
<pnp:Permission>AddAndCustomizePages</pnp:Permission>
<pnp:Permission>BrowseDirectories</pnp:Permission>
</pnp:Permissions>
</pnp:RoleDefinition>
</pnp:RoleDefinitions>
<pnp:RoleAssignments>
<pnp:RoleAssignment Principal="{associatedmembergroup}" RoleDefinition="Deploy Web Parts" />
</pnp:RoleAssignments>
</pnp:Permissions>
</pnp:Security>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>


After applying this provisioning template, you would get the same results as following the steps listed above.

Share:

Add your comment

 
 

 

Archive

Tagcloud

Digital Transformation employee engagement staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics intranet jquery QA Quality Assurance testing digital workspace content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage windows azure cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp SharePoint Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath