@@ -423,21 +423,22 @@ public static Dictionary<string, object> GetFieldValues(PnP.Core.Model.SharePoin
423423 var label = string . Empty ;
424424 var itemId = Guid . Empty ;
425425
426- if ( ! Guid . TryParse ( arrayItem as string , out termGuid ) )
426+ if ( ! Guid . TryParse ( arrayItem ? . ToString ( ) , out termGuid ) )
427427 {
428- var batchedTerm = batch . GetCachedTerm ( termGuid . ToString ( ) ) ;
428+ var batchedTerm = batch . GetCachedTerm ( arrayItem ? . ToString ( ) ) ;
429429 if ( batchedTerm . key == null )
430430 {
431- taxonomyItem = clientContext . Site . GetTaxonomyItemByPath ( arrayItem as string ) as Term ;
431+ taxonomyItem = clientContext . Site . GetTaxonomyItemByPath ( arrayItem ? . ToString ( ) ) as Term ;
432432 if ( taxonomyItem == null )
433433 {
434- throw new PSInvalidOperationException ( $ "Cannot find term { arrayItem } ") ;
434+ throw new PSInvalidOperationException ( $ "Cannot find term ' { arrayItem } ' ") ;
435435 }
436436 var labelResult = taxonomyItem . GetDefaultLabel ( defaultLanguage ) ;
437437 clientContext . ExecuteQueryRetry ( ) ;
438438 label = labelResult . Value ;
439439 itemId = taxonomyItem . Id ;
440- batch . CacheTerm ( termGuid . ToString ( ) , termGuid , label ) ;
440+ batch . CacheTerm ( arrayItem ? . ToString ( ) , itemId , label ) ;
441+ batch . CacheTerm ( itemId . ToString ( ) , itemId , label ) ;
441442 }
442443 else
443444 {
@@ -467,10 +468,12 @@ public static Dictionary<string, object> GetFieldValues(PnP.Core.Model.SharePoin
467468 itemId = batchedTerm . id ;
468469 label = batchedTerm . label ;
469470 }
470- fieldValueCollection . Values . Add ( field . NewFieldTaxonomyValue ( itemId , label ) ) ;
471471 }
472- item [ key as string ] = fieldValueCollection ;
472+
473+ fieldValueCollection . Values . Add ( field . NewFieldTaxonomyValue ( itemId , label ) ) ;
473474 }
475+
476+ item [ key as string ] = fieldValueCollection ;
474477 }
475478 else
476479 {
0 commit comments