Sharepoint 2016 itemupdating afterproperties

Posted by / 26-Sep-2020 12:36

Sometimes that is the most exciting way to learn, but for those less adventurous I will briefly cover the topic here.

You can think of an item event receiver like a database trigger: it has different events that fire during the course of Share Point running an operation on a list item (or document item).

For testing I created a custom list that contains one User field, added the event receiver and overrode all the list item event handlers. The test is repeated when using Classic authentication and when using Claims based authentication.

For every event I tried to get the value of the user field from properties. Also the test is repeated for Share Point 2010 and Share Point 2013.

One small difference between Share Point 2010 and Share Point 2013 is that in Share Point 2010 even if the user field is not changed the After Properties in Item Updating event will have the value “-1;#i:0#.w|domain\user1”.

In Share Point 2013 if the field is not changed then the After Properties in Item Updating event contain the user ID.

When accessing a user field in event receivers there are few differences in the returned values when Classic mode authentication is used from the value when Claims based authentication is used.

What this means is that you cannot store data in instance-level variables and share that data between event handlers.Developing a Sharepoint application would have all the fun of a video game, if only you had infinite lives.Dangers lurk hidden out there which, if you run into them, can be a blow to your project and waste a great deal of time.In the tests user1 and user2 are used and they happen to have ID of 41 and 42.When adding, modifying and deleting item using the UI: You can see that the problem is only with claims based authentication while with classic authentication the results are the same when the item is added/modified using the UI and when it’s added/modified programmatically.

sharepoint 2016 itemupdating afterproperties-32sharepoint 2016 itemupdating afterproperties-4sharepoint 2016 itemupdating afterproperties-5

Hopefully you know about item event receiver if you are having problems with them firing twice.