0

I first I get a site/listitem and store it in variable $page.

$category = $page.FieldValues["myTermField"];

In above, I get the term-value in the field "myTermField" and store it in $category.

I then want to set the value of the $category variable to another field. I tried:

 Set-PnPListItem -List "SitePages" -Identity @myOtherPage -Values @{"myOtherTermField" = $($category);  }

Above does not work. I have tried to put the data in a text-column and it works - I get the term as Label|GUID. However, I want to put all in a managed metadata column and that does not work. I get the error "value cannot be empty".

I also tried:

 Set-PnPTaxonomyFieldValue -ListItem @myOtherPage  -InternalFieldName "myOtherTermField" -Terms @category

Above does not work. Get the error:

Set-PnPTaxonomyFieldValue : Cannot bind parameter 'TermId'. Cannot convert the "Microsoft.SharePoint.Client.Taxonomy.TaxonomyFieldValue" value of type "Microsoft.SharePoint.Clien t.Taxonomy.TaxonomyFieldValue" to type "SharePointPnP.PowerShell.Commands.Base.PipeBinds.GuidPipeBind".

Any help?

0

Try this:

$myOtherTermField = $category -as [Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue];
| improve this answer | |
0

I have answered the same question posted by you in another Technet Thread, please remember to check it:

https://social.technet.microsoft.com/Forums/msonline/en-US/de7406b9-c64d-43c8-97fd-84c7fc88cafe/set-terms-as-value-to-a-list-field-via-powershell?forum=onlineservicessharepoint

You could try the following code, which works for me:

Set-PnPListItem -List "SitePages" -Identity 1 -Values @{"myOtherTermField" = $category.termguid}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.