CSOM和版本历史记录以及2016 Online&服务器 [英] CSOM and Version History with 2016 online & server

查看:59
本文介绍了CSOM和版本历史记录以及2016 Online&服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检索ListItem的版本历史"内容,类似于UI中可用的元数据:不仅是版本,编辑器和签入注释,而且最重要的是,还应用了已更改的属性和数据. >

我尝试使用ChangeQuery,Change& ChangeItem,但仅提供更改类型(更新,系统更新...).

最新的CSOM API是否可用?

Thx

解决方案

如果要使用CSOM跟踪项目字段版本数据更改,我们可以为每个版本字段值循环ListItem.Vesions集合,Console控制台,然后比较更改,例如,比较列表项目标题字段版本"更改:

使用(var clientContext = new ClientContext("https://xxx.sharepoint.com/sites/xxx"))
            {
                //SharePoint Online凭据
                clientContext.Credentials =新的SharePointOnlineCredentials(userName,password);
                //获取SharePoint网站
                Web web = clientContext.Web;
                //加载Web属性
                clientContext.Load(web);
                //对服务器执行查询.
                clientContext.ExecuteQuery();
                //网站属性-显示网站的标题和URL
                Console.WriteLine(标题:" + web.Title +; URL:"+ web.Url);
                var rootweb = clientContext.Web;
                clientContext.Load(rootweb);
                clientContext.ExecuteQuery();
                列表列表= rootweb.Lists.GetByTitle("List1");
                CamlQuery caml = new CamlQuery();
                ListItemCollection listitems = list.GetItems(caml);
                clientContext.Load(listitems);
                clientContext.ExecuteQuery();
                foreach(列表项中的ListItem项)
                {
                    Console.WriteLine("ItemID" + item.Id);
                    ListItemVersionCollection versionCollection = item.Versions;
                    clientContext.Load(versionCollection);
                    clientContext.ExecuteQuery();
                    foreach(versionCollection中的ListItemVersion版本)
                    {
                        Console.WriteLine(version.FieldValues ["Title"]));
                    }
                }
            } 

谢谢

最好的问候


Hi,

I need to retrieve the Version History contents of ListItem similar to the metadata available in the UI : not only the version, editor and check in comments but most importantly, the changes applied on attributes and data that has been changed.

I've tried with ChangeQuery, Change & ChangeItem, but it only provides the change type (update, systemupdate, ...).

Is it available with the most recent CSOM api ?

Thx

解决方案

Hi,

If want to trace the item field version data changes using CSOM, we can loop the ListItem.Vesions collection, Console for each version field value and then compare the changes, for example, compare a list item Title field versions changes:

   using (var clientContext = new ClientContext("https://xxx.sharepoint.com/sites/xxx"))
            {
                // SharePoint Online Credentials  
                clientContext.Credentials = new SharePointOnlineCredentials(userName, password);
                // Get the SharePoint web  
                Web web = clientContext.Web;
                // Load the Web properties  
                clientContext.Load(web);
                // Execute the query to the server.  
                clientContext.ExecuteQuery();
                // Web properties - Display the Title and URL for the web  
                Console.WriteLine("Title: " + web.Title + "; URL: " + web.Url);
                var rootweb = clientContext.Web;
                clientContext.Load(rootweb);
                clientContext.ExecuteQuery();
                List list = rootweb.Lists.GetByTitle("List1");
                CamlQuery caml = new CamlQuery();
                ListItemCollection listitems = list.GetItems(caml);
                clientContext.Load(listitems);
                clientContext.ExecuteQuery();
                foreach (ListItem item in listitems)
                {
                    Console.WriteLine("ItemID " + item.Id);
                    ListItemVersionCollection versionCollection = item.Versions;
                    clientContext.Load(versionCollection);
                    clientContext.ExecuteQuery();
                    foreach (ListItemVersion version in versionCollection)
                    {
                        Console.WriteLine(version.FieldValues["Title"]);
                    }
                }
            }

Thanks

Best Regards


这篇关于CSOM和版本历史记录以及2016 Online&服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆