pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Change AnchorId property for a TaxonomyField #2130

Closed ahmadn82 closed 5 years ago

ahmadn82 commented 5 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

When trying to change the AnchorId property for a TaxonmoyField by changing/updating the field's SchemaXml then updating, the field doesn't change/update the field's SchemaXml (AnchorId property changes the set of terms available for selection in a managed metadata column)

Expected behavior

Updating/changing a field's SchemaXml property - with a new AnchorId - then updating the field, should update/change the field's SchemaXml

Actual behavior

Field SchemaXml property is not updated

Steps to reproduce behavior

Whether you are using Set-PnPField OR $field.UpdateAndPushChanges() Invoke-PnPQuery This doesn't update the field's SchemaXml

https://twitter.com/ahmadn82/status/1139521536442941440

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

3.4.1812.2 SharePointPnPPowerShellOnline

How did you install the PnP-PowerShell Cmdlets?

ghost commented 5 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ahmadn82 commented 5 years ago

Workaround:

Connect-PnPOnline -Url https://my.sharepoint.com/sites/yoursite $field = Get-PnPField -Identity 00000000-0000-0000-0000-000000000000 [Microsoft.SharePoint.Client.Taxonomy.TaxonomyField] $taxonomyFld = [Microsoft.SharePoint.Client.ClientContext].GetMethod("CastTo").MakeGenericMethod([Microsoft.SharePoint.Client.Taxonomy.TaxonomyField]).Invoke($field.Context, $field) $taxonomyFld.AnchorId = '00000000-0000-0000-0000-000000000000' $taxonomyFld.UpdateAndPushChanges($true) Invoke-PnPQuery

wobba commented 5 years ago

@ahmadn82 Figured parsing and verifying the xml would be too complicated. Instead fixed so that Get-PnPField return a TaxonomyField type, so that you can skip the casting line at least. Hope this helps.

JayaPanduRanga commented 3 years ago

I am not able to retrieve the Taxonomy field type using the Get-PnpField command.. Is there an explicit typecast required ?