Monday, August 25, 2008

Update list item without changing the version even versioning is enable on the list

A few days back i need to update metadeta of my document library after uploading the file using custom upload form. I done quickly everything as you know i am not an expert so had left lot of things were pending in that. The main thing was that each time when my code update any item it was counting an update event not create event for server so its create new version each time. Two versions were there within a single second
1. one file upload time
2. one metadata updation time.

I was really fed up.....after a lot of searching i got the solution and writing here for you all guys.

SPList list = site.Lists["MyList"];
SPListItem listItem = list.Items[CurrentFileIndex];
listItem["FileCode"] = strFileCode;
listItem["Comments"] = txtComments.Text;
listItem.SystemUpdate(false);


here the main thing is that we are calling listItem.systemUpdate() method instead of listItem.Update() method.

Hope it will help out you guys.

No comments: