I have a document library for a Meeting Workspace and I would like to enforce that only one document for a content type called Meeting Minutes can be uploaded.

So, when someone tries to upload a second document based on the content type - Meeting Minutes, they should get a message to say minutes already exist.

Can someone provide some sample code on how I can achieve this?

2 Answers 2


I only can think of adding an Event Receiver to the Document Library and check the Content Type. If you have more than one document then you don't allow to add items. You should add this in the ItemAdding event

public override void ItemAdding(SPItemEventProperties properties)
    SPList list = properties.List; 
    string contentTypeName = properties.AfterProperties["ContentType"].ToString(); 
    SPContentType contentType = list.ContentTypes[contentTypeName];

    SPQuery query = new SPQuery();
    query.Query = "<Where><Eq><FieldRef Name='ContentTypeId' /><Value Type='Text'>" + contentType.Id + "</Value></Eq></Where>";

    SPListItemCollection existingItems = properties.List.GetItems(existingItemQuery);
    if (existingItems.Count > 1)
        //Whatever you need


What you can do is create an event receiver to run on the document library, and simply check what the content type of the document being uploaded is.

You then need to check the other document in the library to see if there content type matches your Meeting Minutes.

If one of them does match, just run:

properties.Cancel = true

Your Answer

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

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