Fix Set-PnPListItem not saving taxonomy values when using -Batch parameter #4597
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type
Related Issues?
Fixes #4475
What is in this Pull Request ?
Fix Set-PnPListItem not saving taxonomy values when using -Batch parameter. The -Batch parameter has a different code path when using -Batch and when passing terms in format
TermGroup|TermSet|Term1instead of a guid.The issues fixed related to -Batch and taxonomy terms passed with the format
TermGroup|TermSet|Term1are:fieldValueCollection.Values.Add(field.NewFieldTaxonomyValue(itemId, label));was never called, so the term was never included in the updatesbatch.CacheTerm(termGuid.ToString(), termGuid, label);usedtermGuidafterGuid.TryParse(arrayItem as string, out termGuid)failed, meaning it was always an empty guid 00000000-0000-0000-0000-000000000000, causing any later iteration to return an empty cached termbatch.CacheTerm()now uses as key the formatTermGroup|TermSet|Term1in addition to term id, making the cache useful when all terms are in that format. Before the cache worked only with guid format.Example of running the script:

Script sample similar to the one from #4475