For this we must add the synchronization parameter to our xml definition.Scenario Customer needs to impliment some validations based on user permision , its a common scenario for most of the customers.They need the validation should be varied based on user's sharepoint groups How we handle the validation?
If you before check in your item event receiver only for lookup field, your code will become working incorrectly, when items number in lookup list more than 19.For the lists Those informations are very important to consider when planning a development.Additional information that is important is that during the upload of a document by a user in a library, adding events are triggered after addition of the upload but before the user can fill in themetadata! If you plan to modify the contents of the properties of this document at the event”Item Added”, your users may see a message like this when they will safeguard their metadata: “File ‘mydoc.pdf’ has been modified by ‘user’ the ‘date'”.And Item Added: So, when use class SPField Lookup Value, in Item Adding event Lookup Value equal to null (in . Category is not required field, what if we leave it blank?In Item Updated event as you may know we will have both lookup Id and Lookup Value. Not surprise that we can see something like this (Item Adding): And in Item Updating: So, if you didn't specify lookup, it equal to null or string.empty depending on using .And when we try to update item in IE: It's not expected behavior. When lookup rendered as , and in post back input also sends "0" when we leave lookup blank, but in this situation Share Point works not correctly and set "0" as lookup Id, but when we try get item by this Id, we of course get an exception.In your environment all can work great, but in production you may faced with complex error and spend much time to find a reason of it.When you start diving into deep you will realise that some of the object web developers love to use are you try to access the object like Http Context and SPContext it will be null.So you have to think alternatives before start validation coding in event handlers. Recently I was playing with synchronous item event receivers and lookup fields and found some interesting behavior in different situations.I'll try to describe some pitfalls that I faced when develop item receivers for Share Point. When you try access to a lookup field in such events as always contain only lookup Id, if you want to get lookup value you must query item by id.