locked
Set terms as value to a list field via PowerShell RRS feed

  • Question

  • I first I get a site/list-object and store it in $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?

    Thursday, December 12, 2019 1:21 PM

All replies

  • Hi Akourt,

    Please try the following, works for me:)

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

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, December 13, 2019 2:49 AM
  • Hi,

    Is there anything update?

    If my reply helps you, please mark it as an answer.

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, December 24, 2019 9:41 AM