To update shared fields in a document set using Office 365 Dev PnP PowerShell Cmdlets the following cmdlet can be used:
Set-SPODocumentSetField -Field "fieldname" -DocumentSet "documentsetname" -SetSharedField
This cmdlet sets the field from the available content types to the document set.
‘from the available content types‘
Besides that the functionality isn’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 ‘available content types’?
It seems more plausible to me to make a shared field available at document set level like the UI suggests and explains:
Select which column values for the Document Set should be automatically synchronized to all documents contained in the set.
Enough of the confusion…
In my case I had a field at document set level which I wanted to add to the shared fields collection.
When trying to use the Office 365 Dev PnP PowerShell cmdlet at that level a warning was shown:
Warning: Field not present in document set allowed content types
Luckily PowerShell and CSOM can be used to accomplish this:
$fieldName = "MyText" # field name at document set level $ctName = "MyDocSet" # document set name $ctx = Get-SPOContext $docset = Get-SPODocumentSetTemplate -Identity $ctName $field = $ctx.Web.Fields.GetByInternalNameOrTitle($fieldName) $ctx.Load($field) if($field) { $docset.SharedFields.Add($field) $docset.Update($true) Execute-SPOQuery }
This did not work, Get-SPODocumentSetTemplate is not recognised, do you have a solution
Hi Nes,
Since 2016 the PnP PowerShell cmdlets were renamed from ‘-SPO’ to ‘-PnP’.
You can use Get-PnPDocumentSetTemplate.
Regards, Anita
Any idea if there is a way to accomplish this via an HTTP Post with the Rest API?