pnp / PnP-PowerShell

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

Add-PnPTaxonomyField Only Works for TermSets? #2067

Open smchargue opened 5 years ago

smchargue commented 5 years ago

Add-PnPTaxonomyField seems to support setting the TaxonomyItemId to a Term Set Exclusively, not a Term.

this code

   $term = Get-PnPTermSet -TermGroup $node.TermGroup -Identity $node.TermSet

returns a valid TermSet and then this code works.

   $parameters.Add("TaxonomyItemId", $term.id)                    
   $field = Add-PnPTaxonomyField @parameters -ErrorAction Stop

However, this code, while it return a valid Term ,

$term = Get-PnPTerm -TermGroup $node.TermGroup 
     -TermSet $node.TermSet 
     -Identity $node.TermReference 
     -Recursive 

will fail with the same call.

   $parameters.Add("TaxonomyItemId", $term.id)                    
   $field = Add-PnPTaxonomyField @parameters -ErrorAction Stop

with this message Add-PnPTaxonomyField : Object reference not set to an instance of an object on server. The object is associated with method GetTermSet.

ghost commented 5 years ago

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