简体   繁体   中英

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 cannot 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM