Sunday, April 15, 2007

Sharepoint Tips And Tricks: Synchronous Add List event (ItemAdding) will not give access to item properties

Sharepoint Tips And Tricks: Synchronous Add List event (ItemAdding) will not give access to item properties

Ive been trying to understand how best to handle WSS3's event model and was getting rather bogged down not being able to see any SPItemEventProperties properties on the Async ItemAdding event.

I found I am not alone in my struggles and the link above to Ishai Sagi's blog shows that Microsoft had said that this behaviour is by design. Im not sure how it can be a very helpfull design to fire off an event and then not be able to see what caused that event, however one of the responses to Ishai gives the following code which at least gives some information on what is being added.

foreach (DictionaryEntry de in properties.AfterProperties)
{ string myValue = de.Value;
string myKey = de.Key; }

I'll add more as I find it, but there should be a clearer lead from Microsoft on this rather than just updating thier MSDN examples to ignore this issue.

No comments: