{"id":1029,"date":"2019-04-12T05:31:29","date_gmt":"2019-04-12T05:31:29","guid":{"rendered":"http:\/\/blog.softreeconsulting.com\/?p=1029"},"modified":"2019-04-12T05:31:29","modified_gmt":"2019-04-12T05:31:29","slug":"sharepoint-online","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/","title":{"rendered":"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM)."},"content":{"rendered":"\n<p>Basically, when we are trying to update a SharePoint ListItem\/Document then the item\/file version is increased according to the list versioning. In the Server-side object model, we can update a ListItem without increasing its file version<\/p>\n\n\n\n<p>by\nsetting &#8216;SystemUpdate&#8217; as false. But in CSOM &#8216;SystemUpdate&#8217; property is not\nsupported.<\/p>\n\n\n\n<p>In this below code block, I have mentioned how we can Update a Listitem\/file without changing item\/file version number by using &#8220;ValidateUpdateListItem&#8221; method.<\/p>\n\n\n\n<p>I\nhave used a sample console application to achieve the goal. I have executed the\nbelow code sample for a SPO(O365) server and this will also work for all other\nSharePoint server versions except SP 2010 server.<\/p>\n\n\n\n<p>In the code sample, I have updated the &#8216;Modified User&#8217; and &#8216;Modified Date&#8217; field of a SharePoint document.<\/p>\n\n\n\n<p><strong><u>The code block for this is as mentioned below :<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\nusing System.Security;\nusing System.Collections.Generic;\nusing Microsoft.SharePoint.Client;\n\nnamespace ConsoleApp1\n{\nclass Program\n{\nstatic void Main(string[] args)\n{\nList list = null;\nWeb web = null;\nUser modifiedBy = null;\nListItem item = null;\nClientContext context = null;\nListItemCollection itemCollection = null;\nSecureString pswd = new SecureString();\n\nstring userName = string.Empty;\nstring password = string.Empty;\nstring webUrl = string.Empty;\nstring modifiedDate = string.Empty;\n\ntry\n{\n\/\/ Site Url to scan\nwebUrl = &amp;amp;amp;quot;https:\/\/SiteUrl&amp;amp;amp;quot;;\n\nusing (context = new ClientContext(webUrl))\n{\nuserName = &amp;amp;amp;quot;UserName&amp;amp;amp;quot;;\npassword = &amp;amp;amp;quot;Password&amp;amp;amp;quot;;\n\nforeach (char c in password.ToCharArray())\npswd.AppendChar(c);\n\n\/\/ Setting credential for the above site\ncontext.Credentials = new SharePointOnlineCredentials(userName, pswd);\n\nweb = context.Web;\ncontext.Load(web, w =&amp;amp;amp;gt; w.ServerRelativeUrl, w =&amp;amp;amp;gt; w.Id, w =&amp;amp;amp;gt; w.CurrentUser);\ncontext.ExecuteQuery();\n\n\/\/ Getting list by Title\nlist = context.Web.Lists.GetByTitle(&amp;amp;amp;quot;Documents&amp;amp;amp;quot;);\ncontext.Load(list, L =&amp;amp;amp;gt; L.Id);\n\n\/\/ Getting all items from selected list using caml query\nitemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());\n\n\/\/Loading selected list items\ncontext.Load(itemCollection, IC =&amp;amp;amp;gt; IC.Include(I =&amp;amp;amp;gt; I.Id, I =&amp;amp;amp;gt; I.DisplayName, I =&amp;amp;amp;gt; I.File, I =&amp;amp;amp;gt; I.File.ServerRelativeUrl));\ncontext.ExecuteQuery();\n\n\/\/ The modified date will be changed to below date after the excuted successfully\nmodifiedDate = &amp;amp;amp;quot;20\/01\/2019&amp;amp;amp;quot;;\n\n\/\/ The modified user will be changed to current user after the code excuted successfully\nmodifiedBy = web.CurrentUser;\n\n\/\/ Looping each item\nif (itemCollection != null &amp;amp;amp;amp;&amp;amp;amp;amp; itemCollection.Count &amp;amp;amp;gt; 0)\n{\nfor (int iCount = 0; iCount &amp;amp;amp;lt; itemCollection.Count; iCount++)\n{\ntry\n{\n\/\/getting individual list item from item collection\nitem = itemCollection[iCount];\n\nvar listItemFormUpdateValueColl = new List&amp;amp;amp;lt;ListItemFormUpdateValue&amp;amp;amp;gt;();\nListItemFormUpdateValue listItemFormUpdateValue = new ListItemFormUpdateValue();\nlistItemFormUpdateValue.FieldName = &amp;amp;amp;quot;Modified&amp;amp;amp;quot;;\nlistItemFormUpdateValue.FieldValue = modifiedDate.ToString();\nlistItemFormUpdateValueColl.Add(listItemFormUpdateValue);\n\nitem[&amp;amp;amp;quot;Editor&amp;amp;amp;quot;] = modifiedBy.Id;\nlistItemFormUpdateValue = new ListItemFormUpdateValue();\nlistItemFormUpdateValue.FieldName = &amp;amp;amp;quot;Modified_x0020_By&amp;amp;amp;quot;;\nlistItemFormUpdateValue.FieldValue = modifiedBy.Id.ToString();\n\nlistItemFormUpdateValueColl.Add(listItemFormUpdateValue);\n\n\/\/ This method will update the ListItem properties without increasing file version\nitem.ValidateUpdateListItem(listItemFormUpdateValueColl, true, &amp;amp;amp;quot;&amp;amp;amp;quot;);\ncontext.ExecuteQuery();\n}\ncatch (Exception ex) { }\nbreak;\n}\n}\n}\n}\ncatch (Exception ex) { }\n}\n}\n}\n<\/code><\/pre>\n\n\n\n<p>After\nexecuting the above code, we can find that the &#8216;Modified User&#8217; and &#8216;Modified\nDate&#8217; field value is updated but the Document\/File version remains the same as\nit was before being updated.<\/p>\n\n\n\n<p>In the below screenshot you can verify the difference.<\/p>\n\n\n\n<p><strong><u>Before Update<\/u><\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2019\/08\/Before-Update.jpg\" alt=\"\" class=\"wp-image-5324\"\/><\/figure><\/div>\n\n\n\n<p><strong><u>After Updated<\/u><\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2019\/08\/After-Update.jpg\" alt=\"\" class=\"wp-image-5325\"\/><\/figure><\/div>\n\n\n\n<p><strong>This solution is brought to you by our SharePoint professionals.<\/strong><\/p>\n\n\n\n<p><strong><a href=\"http:\/\/www.softreeconsulting.com\/\">Softree Technolog<\/a><\/strong><a href=\"http:\/\/www.softreeconsulting.com\/\"><strong>y<\/strong><\/a>\u00a0employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.<\/p>\n\n\n\n<p>Be it SPFx or SharePoint add-in developments,\u00a0<strong><a href=\"https:\/\/www.softreetechnology.com\/sharepoint-2019-developments\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"SharePoint 2019 developments (opens in a new tab)\">SharePoint 2019 developments<\/a><\/strong>, web part developments, migrating from SharePoint 2010\/2013 to SharePoint 2013\/2016\/Office 365, Office 365,\u00a0SharePoint hosted apps development\u00a0or something else in SharePoint, we strive to deliver the best<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basically, when we are trying to update a SharePoint ListItem\/Document then the item\/file version is increased according to the list versioning. In the Server-side object model, we can update a ListItem without increasing its file version by setting &#8216;SystemUpdate&#8217; as false. But in CSOM &#8216;SystemUpdate&#8217; property is not supported. In this below code block, I have mentioned how we can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[159,243],"class_list":["post-1029","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-sharepoint-online","tag-update-a-sharepoint-listitem"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM). - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM). - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"Basically, when we are trying to update a SharePoint ListItem\/Document then the item\/file version is increased according to the list versioning. In the Server-side object model, we can update a ListItem without increasing its file version by setting &#8216;SystemUpdate&#8217; as false. But in CSOM &#8216;SystemUpdate&#8217; property is not supported. In this below code block, I have mentioned how we can [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-12T05:31:29+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM). - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/","og_locale":"en_US","og_type":"article","og_title":"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM). - Softree Technology","og_description":"Basically, when we are trying to update a SharePoint ListItem\/Document then the item\/file version is increased according to the list versioning. In the Server-side object model, we can update a ListItem without increasing its file version by setting &#8216;SystemUpdate&#8217; as false. But in CSOM &#8216;SystemUpdate&#8217; property is not supported. In this below code block, I have mentioned how we can [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/","og_site_name":"Softree Technology","article_published_time":"2019-04-12T05:31:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM).","datePublished":"2019-04-12T05:31:29+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/"},"wordCount":287,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2019\/08\/Before-Update.jpg","keywords":["SharePoint Online","update a SharePoint ListItem"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/","name":"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM). - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2019\/08\/Before-Update.jpg","datePublished":"2019-04-12T05:31:29+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#primaryimage","url":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2019\/08\/Before-Update.jpg","contentUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2019\/08\/Before-Update.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/sharepoint-online\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Update a SharePoint ListItem without increasing its item file version using SharePoint Client Side Model(CSOM)."}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/1029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=1029"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/1029\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=1029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=1029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=1029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}