views:

862

answers:

1

I want to restrict entry of new item into sharepoint calendar list with the same from and to dates for the same created user. Let me know this can done, accessing sharepoint object model with C#.

Environment WSS3.0, MOSS 2007, C#

Thanks

A: 

You will need to use a List Event Receiver and tie into the ItemAdding event - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.itemadding.aspx

There's a good tutorial here: http://msdn.microsoft.com/en-us/library/bb736146.aspx

And a good little tool for attaching the event receiver - http://lirliron.blogspot.com/2007/08/moss-list-event-receiver-register_08.html

You can do the check against the To and From and see if there is already an item with that in the list, and if there is set the SPItemEventProperties.Cancel appropriately.

Slace