Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 3 down vote accepted

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).

share|improve this answer
    
Thanks. Now I have started to study how to develop workflows in Visual Studio. –  systemovich Jan 26 '12 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 '12 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. –  systemovich Jan 26 '12 at 14:29

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
    
I also thought of that; however, the Delete privilege might come in handy when the user needs to delete his own draft items. –  systemovich Jan 26 '12 at 14:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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