views:

11

answers:

0

I have a list with multiple items. I don't want the user to delete the list when there are items with running workflows. I'm trying to avoid orphaned workflows and get more control over what the user is allowed to do with data in lists.

I've already implemented a part which denies the user to delete a single item with a running workflow by implementing ItemDeleting

/// <summary>
/// Synchronous before event that occurs before an existing item is completely deleted.
/// Business logic related to deleting items. Checks if there are any problems with deleting the list item.
/// If there are any problems with deleting then the event will be cancelled with an error message. Otherwise deletion is allowed
/// </summary>
/// <param name="properties">
/// A Microsoft.SharePoint.SPItemEventProperties object that represents properties of the event handler.
/// </param>
public override void ItemDeleting(SPItemEventProperties properties)
{
    SPListItem listItem = properties.ListItem;
    foreach (SPWorkflow workflow in listItem.Workflows)
    {
        if (workflow.InternalState == SPWorkflowState.Running)
        {
            properties.Cancel = true;
            properties.ErrorMessage = "It is not allowed to delete items with running workflows. Complete them before deleting";
        }
     }
 }

Now I want to do the same with the list itself, but there is no SPEventReceiverType available to accomplish my task. I've been googling around a little bit, but no luck.

Has anyone done this for Sharepoint 2007?