Skip to content
English
  • There are no suggestions because the search field is empty.

Custom Feature Example: Remove Delete Option for SharePoint Site Members

In this article, learn how to add a new 'permission type' to SharePoint sites that prevents members from deleting content using the provided code.

 

NOTE: These articles are intended to showcase examples of Orchestry's Custom Feature option.  From a product support standpoint, we do not assist in creating or debugging Custom Features.

Getting Started

Before creating a custom feature, check out our introductory articles on:

About this Custom Feature

Need to ensure end users cannot delete content from a SharePoint site?  Use this custom feature to add new permission types that you can assign to your site members.

By assigning this custom feature to any existing SharePoint site, you can assign a new permission level "Edit Without Delete".

 

kbimg-Dec-28-2023-02-39-32-4806-PM

The new 'Edit without Delete" permission type is configured to prevent users from managing site lists, deleting files and file version history.

 

kbimg-Dec-28-2023-02-40-04-8375-PM

Adding the Custom Feature to Orchestry

To add this custom feature to your environment, copy the sample code and the end of the article and save it as a XML file.

 

kbimg-Dec-28-2023-02-32-21-7751-PM


Next, upload only the XML into the Orchestry Template Files. 


kbimg-Dec-28-2023-03-58-13-8649-PM

Next, to distribute the new feature to existing SharePoint sites:

  1. Click the 'Test and Apply' button
  2. In the 'Apply template to web(s)' window, add any SharePoint sites that require the new permission setting
  3. Click 'Apply Template File(s)' to provision the new feature

kbimg-Dec-28-2023-04-23-10-9209-PM

After the provisioning is completed, visit the targeted site(s) and verify that the 'Members' group has been updated to the new 'EditWithoutDelete' permission type.

 

kbimg-Dec-28-2023-04-33-11-4491-PM

Sample XML Code

Copy this code into a .XML file and upload the file as a template in Orchestry:

<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
  <pnp:Preferences Generator="PnP.Framework, Version=1.11.125.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" />
    <pnp:Templates ID="CONTAINER-TEMPLATE-915F72204F064D70AF02904058487FC7">
        <pnp:ProvisioningTemplate ID="TEMPLATE-915F72204F064D70AF02904058487FC7" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite">
            <pnp:Security AssociatedOwnerGroup="{groupsitetitle} Owners" AssociatedMemberGroup="{groupsitetitle} Members" AssociatedVisitorGroup="{groupsitetitle} Visitors">
                <pnp:Permissions>
                    <pnp:RoleDefinitions>
                        <pnp:RoleDefinition Name="EditWithoutDelete">
                            <pnp:Permissions>
                                <pnp:Permission>AddListItems</pnp:Permission>
                                <pnp:Permission>EditListItems</pnp:Permission>
                                <pnp:Permission>ViewListItems</pnp:Permission>
                                <pnp:Permission>OpenItems</pnp:Permission>
                                <pnp:Permission>ViewVersions</pnp:Permission>
                                <pnp:Permission>CreateAlerts</pnp:Permission>
                                <pnp:Permission>BrowseDirectories</pnp:Permission>
                                <pnp:Permission>CreateSSCSite</pnp:Permission>
                                <pnp:Permission>ViewPages</pnp:Permission>
                                <pnp:Permission>BrowseUserInfo</pnp:Permission>
                                <pnp:Permission>UseRemoteAPIs</pnp:Permission>
                                <pnp:Permission>UseClientIntegration</pnp:Permission>
                                <pnp:Permission>Open</pnp:Permission>
                                <pnp:Permission>ViewFormPages</pnp:Permission>
                            </pnp:Permissions>
                        </pnp:RoleDefinition>
                    </pnp:RoleDefinitions>
                    <pnp:RoleAssignments>
                        <pnp:RoleAssignment Principal="{groupsitetitle} Members" RoleDefinition="{roledefinition:Editor}" Remove="true"/>
                        <pnp:RoleAssignment Principal="{groupsitetitle} Members" RoleDefinition="EditWithoutDelete"/>
                    </pnp:RoleAssignments>
                </pnp:Permissions>
            </pnp:Security>
        </pnp:ProvisioningTemplate>
    </pnp:Templates>
</pnp:Provisioning>