List item version is retrieving different (wrong) value.
We have a scenario where we have to compare two version of same list item.
So we think we will use object model and show user what item changed.
But when we had done that we are not able to understand what happen.
We are getting strange behavior in date time field and User (people picker) field.
We are not changing date field but when we are fetching previous version then we are getting around 7 hours different time and sometime because of this it will change the date also.
So for demo I had created a list with two columns
1) “Customuser”
2) “CustomDate”
Then unable the versioning on that list.
Then add item in that list.
Then change the title only, do not change other field what I found is here.
First Version
Second Version
Below is the code to check
ColumnName = "CustomDate";
CurrentVersion = item[ColumnName].ToString();
OldVersion = item.Versions.GetVersionFromLabel("2.0")[ColumnName].ToString();
Values
Currentversion = 4/16/2009 12:00:00 AM
Old version = 4/16/2009 7:00:00 AM
ColumnName = "CustomUser";
CurrentVersion = item[ColumnName].ToString();
OldVersion = item.Versions.GetVersionFromLabel("2.0")[ColumnName].ToString();
Values
CurrentVersion = 7;#SPVM\parth
Old version = 7;#SPVM\parth,#SPVM\parth,#,#,#SPVM\parth
We gor shocked when we checked Created and Created by (Auther) column.
And that column also gives some strange detail.
ColumnName = "Created";
CurrentVersion = item[ColumnName].ToString();
OldVersion = item.Versions.GetVersionFromLabel("2.0")[ColumnName].ToString();
CurrentVersion = 4/16/2009 9:42:41 AM
Old version = 4/16/2009 4:42:41 PM
ColumnName = "Created By";
CurrentVersion = item[ColumnName].ToString();
OldVersion = item.Versions.GetVersionFromLabel("2.0")[ColumnName].ToString();
CurrentVersion = 1;#SPVM\administrator
OldVersion = 1;#SPVM\administrator,#SPVM\administrator,#administrator@sharepoint.local,#,#SPVM\administrator
Now we don’t know how to solve this problem til now
We just share this as we found this scenario. May be is this a bug of sharepoint or we are not able to understand how this functionality works :) ?
5 comments:
good work man..
why don't you send it to Microsoft guys.
Anybody found a solution yet? I am running into the same problem.
nope, not update yet from Microsoft.
We already sent to them.
The time difference might be due to one being in local time.
From documentation: "Unlike all other members in the object model, the indexer for a DateTime field returns values in local time on the site."
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem(v=office.12).aspx
Hay Majid,
Thanks a lot.
this will help a lot of people.
Thanks,
SharepointKings Team
Post a Comment