WSS V3: howto restrict # of items that can be created in a list

Hi.

Is there a simpler way to restrict the # of items that can be created in a sharepoint list either during design time (or) programatically (other than event hooking)

ie., I want to show an error dialog when he clicks on 'New' in the list item creation if the existing item count, say exceeds 5

The problem with event hooking, I guess is inability to show users the dialog...isnt it

Thanks




Answer this question

WSS V3: howto restrict # of items that can be created in a list

  • KitGreen

    It works in synchronous events like itemAdding, but in asynchronous event like item Added doesn't.
  • http://www.ilkon.com

    true. that is how it is designed. asynch events are in the background, and the user isn't aware of them, and there is no way of raising errors.

    I would suggest using email as a way of notifying users of errors in asynch events. you just have to code it to get the user's email address.



  • Amin_msw

    set

    e.cancel = true

    and

    e.errormessage = "whatever text you want to display"..



  • BobH

    How can I show a error message in ItemAdded event

    Thanks


  • kforrey

    This is actually something that microsoft gave us in the 2007 version - a synchronous event handler. just write a bit of C# (easy) that limits the # of items in the "ItemAdding" event, and cancels the user's action and shows him a message:

    properties.Cancel = true;
    properties.ErrorMessage = "The list has too many items!";

    The user will get displayed the error message when you do the code above in the ItemAdding event (not in the ItemAdded event!)



  • WSS V3: howto restrict # of items that can be created in a list