如何使用.Net客户端对象模型读取sharepoint自定义列表字段的版本历史记录 [英] How to read version history of a sharepoint custom list field using .Net Client Object model
问题描述
我在网站上有一个SharePoint列表。它有一个自定义列表。我添加了一个类型为多行文本的新字段,并在附加列设置部分中选择了将更改附加到现有文本 - >是。当我们修改列表项时,我们只在该字段中获得了更改。我们如何使用.Net客户端对象模型读取所有更改。
我们在服务器对象模型中实现的同样问题
public static string GetVersionedMultiLineTextAsPlainText(SPListItem item,string key)
{
StringBuilder sb = new StringBuilder();
$ / $
foreach(item.Web.Lists中的SPListItemVersion版本[item.ParentList.ID] .Items [item.UniqueId]。版本)
{
SPFieldMultiLineText字段= version.Fields [key] as SPFieldMultiLineText;
if(field!= null)
{
string comment = field.GetFieldValueAsText(version [key]);
if(comment!= null && comment.Trim()!= string.Empty)
{
sb.App结束();
sb.Append(version.CreatedBy.User.Name).Append(();
sb.Append(version.Created.ToString(MM / dd / yyyy hh:mm tt));
sb。追加());
sb.Append(评论+';');
}
}
}
返回sb.ToString();
}
相同代码需要写入.Net客户端对象模型。
任何人都可以帮助这个代码。
Hi,
I have a SharePoint List in site. It has a custom list. I added a new field with type 'Multiple lines of Text' and in Additional Column Setting section selected 'Append Changes to the existing text'-->yes. When we modified list item we got the changes in that field only. How can we read the all the changes using .Net client object model.
Same problem we achieved in server object model like this way
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();
}
same code need to write in .Net client object model.
Can any one help this code.
推荐答案
你可以使用以下功能:
You can use below function:
function displayCostSheetComments() {
()。SPServices({
操作: GetVersionCollection,
async: true ,
strlistID: yourListName,
strlistItemID: yourListItemId,
strFieldName: yourFieldnName,
completefunc: function (xData,Status){
().SPServices({ operation: "GetVersionCollection", async: true, strlistID: "yourListName", strlistItemID: "yourListItemId", strFieldName: "yourFieldnName", completefunc: function (xData, Status) {
(xData.responseText).find( Version)。each( function (i){
< span class =code-keyword> var comments = {
用户:
(xData.responseText).find("Version").each(function (i) { var comments = { User:
这篇关于如何使用.Net客户端对象模型读取sharepoint自定义列表字段的版本历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!