{"id":2185,"date":"2016-10-07T15:19:31","date_gmt":"2016-10-07T13:19:31","guid":{"rendered":"http:\/\/www.itidea.nl\/?p=2185"},"modified":"2016-10-04T16:14:19","modified_gmt":"2016-10-04T14:14:19","slug":"update-shared-fields-in-a-document-set","status":"publish","type":"post","link":"https:\/\/www.itidea.nl\/index.php\/update-shared-fields-in-a-document-set\/","title":{"rendered":"Update shared fields in a document set"},"content":{"rendered":"<p>To update shared fields in a document set using Office 365 Dev PnP PowerShell Cmdlets the following cmdlet can be used:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nSet-SPODocumentSetField -Field &quot;fieldname&quot; -DocumentSet &quot;documentsetname&quot; -SetSharedField\r\n<\/pre>\n<p>This cmdlet sets the field from the available content types to the document set.<br \/>\n&#8216;<em>from the available content types<\/em>&#8216;<br \/>\nBesides that the functionality isn&#8217;t available in the UI, the functionality seems a little bit odd, especially when multiple content types are available in the document set. Why share fields at the level of &#8216;available content types&#8217;?<br \/>\nIt seems more plausible to me to make a shared field available at document set level like the UI suggests and explains:<\/p>\n<blockquote><p>Select which column values for the Document Set should be automatically synchronized to all documents contained in the set.<\/p><\/blockquote>\n<p>Enough of the confusion&#8230;<br \/>\nIn my case I had a field <em>at document set level<\/em> which I wanted to add to the shared fields collection.<\/p>\n<p>When trying to use the Office 365 Dev PnP PowerShell cmdlet at that level a warning was shown:<\/p>\n<blockquote><p>Warning: Field not present in document set allowed content types<\/p><\/blockquote>\n<p>Luckily PowerShell and CSOM can be used to accomplish this:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$fieldName = &quot;MyText&quot; # field name at document set level\r\n$ctName = &quot;MyDocSet&quot; # document set name\r\n\r\n$ctx = Get-SPOContext\r\n$docset = Get-SPODocumentSetTemplate -Identity $ctName\r\n\r\n$field = $ctx.Web.Fields.GetByInternalNameOrTitle($fieldName)\r\n$ctx.Load($field)\r\n\r\nif($field)\r\n{\r\n $docset.SharedFields.Add($field)\r\n $docset.Update($true)\r\n Execute-SPOQuery\r\n}\r\n<\/pre>\n<p><a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2016\/10\/DocSet_MyDocSet1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2202\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2016\/10\/DocSet_MyDocSet1.png\" alt=\"DocSet_MyDocSet\" width=\"858\" height=\"614\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2016\/10\/DocSet_MyDocSet1.png 858w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2016\/10\/DocSet_MyDocSet1-300x214.png 300w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2016\/10\/DocSet_MyDocSet1-600x429.png 600w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To update shared fields in a document set using Office 365 Dev PnP PowerShell Cmdlets the following cmdlet can be used: Set-SPODocumentSetField -Field &quot;fieldname&quot; -DocumentSet &quot;documentsetname&quot; -SetSharedField This cmdlet sets the field from the available content types to the document &#8230; <a class=\"more-link\" href=\"https:\/\/www.itidea.nl\/index.php\/update-shared-fields-in-a-document-set\/\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,22,35],"tags":[37,43,44],"class_list":["post-2185","post","type-post","status-publish","format-standard","hentry","category-office-365","category-powershell","category-sharepoint-2013","tag-office365","tag-powershell","tag-sharepoint-2013"],"_links":{"self":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/comments?post=2185"}],"version-history":[{"count":15,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2185\/revisions"}],"predecessor-version":[{"id":2203,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2185\/revisions\/2203"}],"wp:attachment":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/media?parent=2185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/categories?post=2185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/tags?post=2185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}