Example:
In custom list we have field “Comments” and it’s type is Multi Line Text with Version and selected ”Allow append text” as option, now if we want to check all Versioned Comments /History of comments with entered text, date and time and person name then if we try to access it’s field value programmatically by list item then it will always returns latest version.
Below code will explain and demonstrate how we can take version of multiline text values with username, date and time.
public static string GetVersionedMultiLineTextAsPlainText(SPListItem item, string key)
{
StringBuilder sb = new StringBuilder();
foreach (SPListItemVersion version in item.Web.Lists[item.ParentList.ID].Items[item.UniqueId].Versions)
{
SPFieldMultiLineText field = version.Fields[key] as SPFieldMultiLineText;
if (field != null)
{
string comment = field.GetFieldValueAsText(version[key]);
if (comment != null && comment.Trim() != string.Empty)
{
sb.Append("");
sb.Append(version.CreatedBy.User.Name).Append(" (");
sb.Append(version.Created.ToString("MM/dd/yyyy hh:mm tt"));
sb.Append(") ");
sb.Append(comment);
}
}
}
return sb.ToString();
}
Showing posts with label Multiple Line - Sharepoint. Show all posts
Showing posts with label Multiple Line - Sharepoint. Show all posts
Wednesday, June 17, 2009
How to get Versioned Multi Line Text as Plain Text of Multiline Text (Append Text/Version Applies) Field in SharePoint
Labels:
comments,
date and time,
History of MultiLie Text Progrmatically,
How to get Versioned Multi Line Text as Plain Text of Multiline Text (Append Text/Version Applies) Field in SharePoint,
How to get Versioned MultiLine Text As Plain Text of MultilineText(Append Text/Version Applies) Field in Sharepoint,
MultiLine Append Text,
MultiLine Version,
MultiLine Version and Append Text,
Multiple Line - Sharepoint,
Multiple Line - Version,
Programatically take versioned data from MultiLine Text,
Sharepoint,
Sharepoint MultiLine,
Sharepoint MultiLine Text,
Sharepoint Multiple Line,
Sharepoint- MultiLine Field,
version of multiline text values with username
Subscribe to:
Posts (Atom)