0

I am working on a SharePoint 2013 on-premises farm. and i have added an ItemUpdated event receiver for my custom list, as follow:-

public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);
            var abcd = properties.AfterProperties["OrderInternalStage2"];
            var abcd2 = properties.ListItem["OrderInternalStage2"];

now in my case the OrderInternalStage2 is a hidden field inside the content type. And if i check the value using properties.ListItem["OrderInternalStage2"] the value will be correct, but inside the properties.AfterProperties["OrderInternalStage2"]; the value will always be null??? now if i change the field from being hidden to optional, then the value will be presented inside the properties.AfterProperties["OrderInternalStage2"]; .. so i am not sure what is the reason behind this behavioure, why hidden fields will be null inside the AfterProperties for the Itemupdated event recevier ??

Thanks

0

The reason if a hidden column has a default value and when you hit save it saves it by default. In an event receiver when you hit save afterproperties is responsible to show 'newly changed' value which is NULL correct behaviour when the column is hidden.

Reference Before vs After properties and MSDN Documentation

  • @little_bi_thoughts but in my case the hidden field does not have a defualt value, where i am controlling its value inside my ER code. but i can capture its value using properties.ListItem["OrderInternalStage2"] correctly, but if i try to capture its value using properties.AfterProperties["OrderInternalStage2"]; it will always be null.. also when i submit a new or edit form the properties.AfterProperties will show all the fields values (not just the updated ones) and in the ItemUpdated case the current and after properties should always be the same.. – john Gu Feb 8 '18 at 11:20
  • .. but for hidden fields they will be null in the After case.. which is i am asking why ? – john Gu Feb 8 '18 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.