Skip to content

Fixed issue with Guid values not being supported for "TaxonomyFieldType" fields in batch scenarios (Set-PnPListItem, Add-PnPListItem)#5174

Open
reusto wants to merge 3 commits into
pnp:devfrom
reusto:fix/setlistitemtermguid
Open

Fixed issue with Guid values not being supported for "TaxonomyFieldType" fields in batch scenarios (Set-PnPListItem, Add-PnPListItem)#5174
reusto wants to merge 3 commits into
pnp:devfrom
reusto:fix/setlistitemtermguid

Conversation

@reusto

@reusto reusto commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Type

  • Bug Fix
  • New Feature
  • Sample

What is in this Pull Request ?

Fixed the following issues for fields of type TaxonomyFieldType for Add/Set-PnPListItem command when used in a batch scenario:

  • Field couldn't be set by providing the term as Guid
  • Term wasn't cached in batch properly when providing the term as path
  • Error handling when term does not exist

This already worked previously for fields of type TaxonomyFieldTypeMulti therefor I extracted the code for both variants to a single additional helper function so that both share the same code now.

…pe" fields in batch scenarios (Set-PnPListItem, Add-PnPListItem)

Unified handling of input values for taxonomy items when using batch.
@KoenZomers

Copy link
Copy Markdown
Collaborator

@erwinvanhunen Could you have a look at this one please?

@KoenZomers KoenZomers requested review from KoenZomers and removed request for erwinvanhunen June 26, 2026 08:28
@KoenZomers

Copy link
Copy Markdown
Collaborator

Sorry for the long time before we process this PR @reusto. I've just tried to reproduce the issue on our latest dev branch, so without applying your PR, and it seems to be working fine for me. Might be doing something different than what you did when you ran into this issue. Can you elaborate what could be different in my test case?

$b = New-PnPBatch
add-pnplistitem -List "PR5174" -Values @{"Title"="2";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
add-pnplistitem -List "PR5174" -Values @{"Title"="3";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
add-pnplistitem -List "PR5174" -Values @{"Title"="4";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
add-pnplistitem -List "PR5174" -Values @{"Title"="5";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
add-pnplistitem -List "PR5174" -Values @{"Title"="6";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
add-pnplistitem -List "PR5174" -Values @{"Title"="7";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
add-pnplistitem -List "PR5174" -Values @{"Title"="8";"Test"="17f0e25e-0a3c-4309-af3b-f95df3139bf1"} -Batch $b
Invoke-PnPBatch -Batch $b

image

@reusto

reusto commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@KoenZomers No problem.

Providing the term guid as a string is working fine, but not if the term id is given as type of GUID e.g. when directly using the output from Get-PnPTerm.
This is caused by value as string when trying to parse the GUID, everywhere else in the class it was already changed to value?.ToString() just not for this one case.

Therefor the test should look like this:

$term = Get-PnPTerm -Identity "17f0e25e-0a3c-4309-af3b-f95df3139bf1"
$termGuid = [Guid]::new("17f0e25e-0a3c-4309-af3b-f95df3139bf1")

$b = New-PnPBatch
add-pnplistitem -List "PR5174" -Values @{"Title"="2";"Test"=$term.Id} -Batch $b;
add-pnplistitem -List "PR5174" -Values @{"Title"="3";"Test"=$termGuid} -Batch $b;

Invoke-PnPBatch -Batch $b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants