views:

33

answers:

2

Hi,

I have a choice field called stage lets assume it has following values used as a dropdown

stage1
stage2
stage3

on change of stage I would like to record TimeStamp and Who updated the item information

How can I do it on my List without creating any other list, I think using Versioning I can add a new version whenever before and after properties are change on that Field.

//ItemUpdating Event 
if(properties.ListItem["Stage"] != properties.AfterProperties["Stage"])
{
   //Create a Version;
}

I cannot find how to create a version here, Please guide.

Thnaks Amit

A: 

I'm not sure I understand the question. If you have versionning enabled, don't you have this info already under version history? Why do you need to develop anything new?

Vladi Gubler
I need this because I am trying to create a log which can record whenever there is the change in "Stage" of the item i am not bothered about other changes but since Enabling Versioning will track any change made to the item it does not fit in.
Amit
Hmm, how about programmatically deleting versions if the Stage was not changed in them? let's say, an event receiver?
Vladi Gubler
+2  A: 

if you have versioning enabled, every time you call SPListItem.Update method, SharePoint automatically creates new version.

If you don't want new version to be created, call UpdateOverwriteVersion.

If you don't want to modify Modified By and Modified fields, then call SystemUpdate (see overloaded SystemUpdate, where you pass argument also not to create new version).

Janis Veinbergs
thanks for the help but I am having a Event Handler for the List where I am check weather to create a version or not Since I now know how to disable versioning but I am unable to apply it , where do i actually do it in ItemUpdated or ItemUpdating or eleswhere ?
Amit
Versioning is enabled in the list settings. Settings -> List Settings -> Versioning Settings
Kit Menke
You usally do not check weather to create version or not - just call the update method. If versioning will be enabled - version will be created. If not enabled - not created.UpdateOverwriteVersion and SystemUpdate methods are EXCEPTIONAL and you use them only to specify that you REALLY do not want to create new version.
Janis Veinbergs