I want to prevent users from overwriting items that have the same name. When users add items to a library there is a checkbox indicating files should be overwritten if they have the same name. In this case I want to enforce that on every submit. I am thinking of an event receiver for ItemAdding but it does not seem to fire if you upload the same document a second time. What is the best approach/technique to create this functionality?
Tell me more
×
SharePoint Stack Exchange is a question and answer site for
SharePoint enthusiasts. It's 100% free, no registration required.
|
This is a tough one as in ItemUpdating Event both BeforeProperties and AfterProperties are null. So it becomes difficult to detect the difference between a file being overwritten vs. a property being edited. I had the same requirement once and I have blogged about it here: http://sharepointnadeem.blogspot.in/2011/12/prevent-duplicate-files-to-be-uploaded.html |
|||
|
|
|
You might need to attach to ItemUpdating instead. |
|||||
|
|
I am not sure how reliable this is but I found this to be working very well. This code is placed in the ItemUpdating method.
I would like to hear comments on this approach on how reliable it is. |
|||
|
|
