Refactor taxonomy term parsing and remove redundant code in migration script

This commit is contained in:
Torsten Brendgen
2026-04-16 16:33:32 +02:00
parent 68d7ca6755
commit 6c5236a405

View File

@@ -1942,13 +1942,10 @@ function Convert-ToTaxonomyTermEntries {
$label = $matches[1] $label = $matches[1]
$termGuid = $matches[2] $termGuid = $matches[2]
} }
else { elseif ([guid]::TryParse($rawTermString, [ref]([guid]::Empty))) {
$parsedGuid = [Guid]::Empty
if ([guid]::TryParse($rawTermString, [ref]$parsedGuid)) {
$termGuid = $rawTermString $termGuid = $rawTermString
} }
} }
}
if ([string]::IsNullOrWhiteSpace($label) -and -not [string]::IsNullOrWhiteSpace($TextValue) -and $rawTerms.Length -le 1) { if ([string]::IsNullOrWhiteSpace($label) -and -not [string]::IsNullOrWhiteSpace($TextValue) -and $rawTerms.Length -le 1) {
$label = $TextValue $label = $TextValue
@@ -2187,14 +2184,6 @@ function Set-SPItemFieldValue {
try { try {
switch ($field.TypeAsString) { switch ($field.TypeAsString) {
"TaxonomyFieldType" {
Set-SPTaxonomyFieldValue -Item $Item -Field $field -RawValue $RawValue -TextValue $TextValue
return
}
"TaxonomyFieldTypeMulti" {
Set-SPTaxonomyFieldValue -Item $Item -Field $field -RawValue $RawValue -TextValue $TextValue
return
}
"Boolean" { "Boolean" {
$Item[$field.InternalName] = Convert-ToBoolean -RawValue $RawValue -TextValue $TextValue $Item[$field.InternalName] = Convert-ToBoolean -RawValue $RawValue -TextValue $TextValue
return return