SharePoint - checking Content Approval change status in event receiver

I have a SharePoint list with Content Approval enabled. The business requirement is that once the new list item is approved it should stay approved despite further updates by any user.

My first thought was to handle the ItemUpdating method, and if the corresponding before property is Approved then set the after property to Approved. This doesn't work however.

In the ItemUpdating method the "Approval Status" column does not show up in properties.BeforeProperties or properties.AfterProperties. properties.ListItem["Approval Status"] and properties.ListItem.ModerationInformation.Status both show the "before" value. In the ItemUpdated method the situation is the same, except instead the values shown are the "after" values.

Is there a way in either method to identify both the before and after methods? I can work around this by creating a new hidden column that I set when the item is approved but that doesn't seem best.

Should I be approaching this from a workflow perspective?

13.10.2009 18:35:52
13.10.2009 19:02:09
unfortunately "Approval Status"/"_ModerationStatus doesn't appear in the BeforeProperties or AfterProperties collections.
Chloraphil 13.10.2009 19:21:35
_ModerationStatus does appear in the AfterProperties collection (when it is changed, of couse). Not sure how I missed it before.
Chloraphil 22.10.2009 16:54:10

Use field's internal name with AfterProperties or BeforeProperties. i.e. properties.AfterProperties["internal name"].

It works for me

30.10.2010 08:05:39

Please refer to the following properties in the AfterProperties section for a document library.

Document libraries are a bit different than lists. the doc libraries have .AfterProperties["vti_doclibmodstat"] and .AfterProperties["vti_doclibmodcomm"].

2.08.2013 16:34:10