Hi Guys ,
Some times we come across a situation where we need to know the latest list item version .
Please find the method to get the latest list item version using Server object model.
Public SPListItem TopListItemVersion(SPListItem item)
{
if ((item.Versions != null) && (item.Versions.Count > 0))
{
SPListItemVersionCollection versions = item.Versions;
SPListItem latestItemversion;
if (item.Versions.Count > 1)
latestItemversion= item.Versions[item.Versions.Count - 1].ListItem;
else
latestItemversion= item.Versions[0].ListItem;
return latestItemversion;
}
else
return item;
}
No comments :
Post a Comment