Skip to content

Commit 006dea3

Browse files
authored
Merge branch 'dev' into NewGraphHelper
2 parents 3e19244 + 472a561 commit 006dea3

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Commands/Model/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ public void Save()
6666
}
6767
}
6868
}
69-
}
69+
}

src/Commands/Utilities/ListItemHelper.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)