Cannot distinguish new Item or updated Item in Event Receiver, enforce unique values case!

Pergunta Cannot distinguish new Item or updated Item in Event Receiver, enforce unique values case!

  • 2010年12月29日 14:52
     
     

    When programming with an event handler used for a document library, there is no properties in a new listitem. The best way is to use the itemupdating event to get it's synchronous process into work.

    I used to know if my listitem is new or not when  properties.listitem["Column"] is null or having a default value. But in SharePoint 2010 there is the enforce unique values property that I find useful. But this property triggers the itemupdating too ! and what's more embarrassing is when someone types a value wich is not unique, the properties.listitem wont be null anymore !

    Is there another way to distinguish a new element in itemupdating event or is there a property that tells when it's a "enforce unique values event" or not ?

     

    Thanks


    Share is what this world is all about!

すべての返信

  • 2010年12月31日 6:54
     
     

    Hi,

     

    Did you mean setting EnforceUniqueValues property could also trigger itemupdating event?

    However, as I tested, this could not fire itemupdating,  please correct me if I miss something.

     

    Best Regards,

    Aaron

  • 2010年12月31日 8:41
     
     

    I wasn't talking about setting the EnforceUniqueValues property in code, but about the Enforce unique values property (radiobutton) assigned to a column when created under a document library. To reproduce this, just make a column with that property and when creating a new item under the document library try to put a value that is already used and then save. It will trigger the itemupdating event and then tell you (under the field ,in red) that you must change the value. When changing the value again and submitting the properties.lisitem["column"] isn't null anymore...

    Thanks Aaron


    Share is what this world is all about!