Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/Commands/Utilities/ListItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,21 +423,22 @@ public static Dictionary<string, object> GetFieldValues(PnP.Core.Model.SharePoin
var label = string.Empty;
var itemId = Guid.Empty;

if (!Guid.TryParse(arrayItem as string, out termGuid))
if (!Guid.TryParse(arrayItem?.ToString(), out termGuid))
{
var batchedTerm = batch.GetCachedTerm(termGuid.ToString());
var batchedTerm = batch.GetCachedTerm(arrayItem?.ToString());
if (batchedTerm.key == null)
{
taxonomyItem = clientContext.Site.GetTaxonomyItemByPath(arrayItem as string) as Term;
taxonomyItem = clientContext.Site.GetTaxonomyItemByPath(arrayItem?.ToString()) as Term;
if (taxonomyItem == null)
{
throw new PSInvalidOperationException($"Cannot find term {arrayItem}");
throw new PSInvalidOperationException($"Cannot find term '{arrayItem}'");
}
var labelResult = taxonomyItem.GetDefaultLabel(defaultLanguage);
clientContext.ExecuteQueryRetry();
label = labelResult.Value;
itemId = taxonomyItem.Id;
batch.CacheTerm(termGuid.ToString(), termGuid, label);
batch.CacheTerm(arrayItem?.ToString(), itemId, label);
batch.CacheTerm(itemId.ToString(), itemId, label);
}
else
{
Expand Down Expand Up @@ -467,10 +468,12 @@ public static Dictionary<string, object> GetFieldValues(PnP.Core.Model.SharePoin
itemId = batchedTerm.id;
label = batchedTerm.label;
}
fieldValueCollection.Values.Add(field.NewFieldTaxonomyValue(itemId, label));
}
item[key as string] = fieldValueCollection;

fieldValueCollection.Values.Add(field.NewFieldTaxonomyValue(itemId, label));
}

item[key as string] = fieldValueCollection;
}
else
{
Expand Down
Loading