【问题标题】:Accessing properties in a SharePoint 2010 ListItem for version history访问 SharePoint 2010 ListItem 中的属性以获取版本历史记录
【发布时间】:2013-04-02 23:08:17
【问题描述】:

我有一个自定义应用程序,它使用 SharePoint 2010 来存储列表项并对这些项进行版本控制。搜索正在通过搜索服务进行,并且更新正在使用客户端对象模型成功。我们现在正尝试检索旧版本列表项的自定义属性以显示给用户,类似于 SharePoint 显示历史信息的方式,它在哪里提取文件版本,然后显示已更改属性的列表。

现在我们有以下内容,但该文件的版本没有显示任何可显示的属性,即使当我们在屏幕上查看历史记录时 SharePoint 确实显示了更改。

using (ClientContext context = new ClientContext(spURL)) {
    Web site = context.Web;
    context.Load(site);
    context.ExecuteQuery();

    File file = site.GetFileByServerRelativeUrl(sRelativeObjectPath);
    context.Load(file);

    context.ExecuteQuery();

    FileVersionCollection versions = file.Versions;
    context.Load(versions);
    context.ExecuteQuery();

    foreach (FileVersion ver in versions)
    {
        File verFile = site.GetFileByServerRelztiveUrl(ver.Url);
        context.Load(verFile, f => f.ListItemAllFields);

        //verFile.ListItemAllFields.FieldValues are null, need to get the properties of the ListItem


    } 
}

关于我应该如何提取版本的属性值有什么想法吗?这不在 SharePoint 中运行,因此我无权访问 SharePoint.dll 以使用 SPQuery 和 SPItem。

【问题讨论】:

  • 看起来你只需要“context.ExecuteQuery();”在“context.Load(verFile, f => f.ListItemAllFields);”之后。
  • @vinny +1,我没有阅读完整的源代码……

标签: c# sharepoint sharepoint-2010 csom


【解决方案1】:

File 类中有File.ListItemAllFields property,您可以使用关联的列表项及其字段。

【讨论】:

  • 请描述更多和一些例子......在这里......请......如果可能的话,描述如何获取属性,如上次修改日期或该版本创建的日期......或创建它的用户名。或如何通过最新版本获取特定属性,如数字和差异
猜你喜欢
  • 2011-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多