How to Create a new Version Programmatically in Sharepoint List
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 cann开发者_如何学JAVAot find how to create a version here.
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).
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?
精彩评论