@@ -423,21 +423,22 @@ public static Dictionary<string, object> GetFieldValues(PnP.Core.Model.SharePoin
423
423
var label = string . Empty ;
424
424
var itemId = Guid . Empty ;
425
425
426
- if ( ! Guid . TryParse ( arrayItem as string , out termGuid ) )
426
+ if ( ! Guid . TryParse ( arrayItem ? . ToString ( ) , out termGuid ) )
427
427
{
428
- var batchedTerm = batch . GetCachedTerm ( termGuid . ToString ( ) ) ;
428
+ var batchedTerm = batch . GetCachedTerm ( arrayItem ? . ToString ( ) ) ;
429
429
if ( batchedTerm . key == null )
430
430
{
431
- taxonomyItem = clientContext . Site . GetTaxonomyItemByPath ( arrayItem as string ) as Term ;
431
+ taxonomyItem = clientContext . Site . GetTaxonomyItemByPath ( arrayItem ? . ToString ( ) ) as Term ;
432
432
if ( taxonomyItem == null )
433
433
{
434
- throw new PSInvalidOperationException ( $ "Cannot find term { arrayItem } ") ;
434
+ throw new PSInvalidOperationException ( $ "Cannot find term ' { arrayItem } ' ") ;
435
435
}
436
436
var labelResult = taxonomyItem . GetDefaultLabel ( defaultLanguage ) ;
437
437
clientContext . ExecuteQueryRetry ( ) ;
438
438
label = labelResult . Value ;
439
439
itemId = taxonomyItem . Id ;
440
- batch . CacheTerm ( termGuid . ToString ( ) , termGuid , label ) ;
440
+ batch . CacheTerm ( arrayItem ? . ToString ( ) , itemId , label ) ;
441
+ batch . CacheTerm ( itemId . ToString ( ) , itemId , label ) ;
441
442
}
442
443
else
443
444
{
@@ -467,10 +468,12 @@ public static Dictionary<string, object> GetFieldValues(PnP.Core.Model.SharePoin
467
468
itemId = batchedTerm . id ;
468
469
label = batchedTerm . label ;
469
470
}
470
- fieldValueCollection . Values . Add ( field . NewFieldTaxonomyValue ( itemId , label ) ) ;
471
471
}
472
- item [ key as string ] = fieldValueCollection ;
472
+
473
+ fieldValueCollection . Values . Add ( field . NewFieldTaxonomyValue ( itemId , label ) ) ;
473
474
}
475
+
476
+ item [ key as string ] = fieldValueCollection ;
474
477
}
475
478
else
476
479
{
0 commit comments