1

Contributors have the Delete privilege.

In libraries and lists with Content Approval switched on, our policy is:

  • Contributors may not delete draft items submitted by other users.
  • Contributors may not delete items with running workflows.
  • Contributors may not delete approved items.

I am attempting to build a workflow (called Deletion) in Sharepoint Designer to enforce this policy. (I think a workflow is much better than creating a custom permission level based on the Contribute permission but with the Delete privilege removed.)

The Deletion workflow should be started automatically when a Contributor attemps to delete an item, for example by clicking the Delete item on the item's Edit menu. In Sharepoint Designer, on the workflows settings page in the Start Options section, there are only options for starting the workflow when the item is created or changed.

I think I have to catch an event like BeforeItemDelete or something like that.

4 Answers 4

4

When set through the UI, workflows can only act on the following events: ItemAdded, ItemUpdated. (You can also start workflows manually)

What you want is to block the ItemDeleting event. The "ing" ending implies your trap occurs before the event, not after, which would be pointless in your case.

So, what you want is an event receiver on the ItemDeleting event, e.g. code with a WSP feature deployment.

Sample function body:

public override void ItemDeleting(SPItemEventProperties properties)
{
       base.ItemDeleting(properties);

       if (... conditions to match ...)
       {
         properties.Cancel = true;
         properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
         properties.RedirectUrl = "/_layouts/DeletingEventReceiver/ErrorPage.aspx";
       }
}

Note that you could also use code to hook a workflow on same ItemDeleting event, but it would bring more overhead (starting the workflow).

3
  • Thanks. Now I have started to study how to develop workflows in Visual Studio.
    – Geoffrey
    Jan 26, 2012 at 14:00
  • If you are going to provision code, for this specific requirements I would use an event receiver over a workflow. You want to act on the "before" event, which is synchronous (e.g. happening in the same thread of execution), and want to minimize overhead. Coding and deploying the event receiver is also easier.
    – Louis
    Jan 26, 2012 at 14:10
  • I found out that I need a Sharepoint server installed on my computer. I will have to ask someone in the IT department to implement this for us. The event receiver should be enough. The reason I was thinking of a workflow was that it might happen that the Contributor has a valid reason for the deletion of some item. The workflow would then pass the decison on to someone who can delete the item.
    – Geoffrey
    Jan 26, 2012 at 14:29
1

you can have different permissions in your impersonation rule - so just give full rights to the person that created it, and no delete rights to whoever else is in your non-creator group

0

For scenarios like this, I typically "fool" the system. I give users a custom permission level that does not have delete privileges. In the list item I have a field called Delete that's either a check box or a choice field. When the user edits the item and selects Yes or ticks the box, the item appears deleted as it get hidden from all views.

If you're on 2010, you can use an impersenation step in the workflow to delete the item.

1
  • I also thought of that; however, the Delete privilege might come in handy when the user needs to delete his own draft items.
    – Geoffrey
    Jan 26, 2012 at 14:02
0

I found a useful and pragmatic approach to working around the inability of SharePoint to trigger a workflow on deletion. Effectively getting the user to manually start a "delete" workflow, replacing the "Delete" action from the item's context menu. The bonus here is that it can all be handled within SharePoint Designer and doesn't require any custom code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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