-
Notifications
You must be signed in to change notification settings - Fork 217
Closed
Labels
area: model 📐Related to the core SDK modelsRelated to the core SDK modelsbugSomething isn't workingSomething isn't working
Description
Category
- Bug
Describe the bug
Using the sample code from the documentation to traverse a TermSet, an exception is produced if you attempt to go more than 2 levels deep.
The exception is:
PnP.Core.MicrosoftGraphServiceException: 404Code: itemNotFoundMessage: Term with id 96bd5df3-b4a9-490b-8a4a-796e9d15177b not found
Where the id is the id of the term who's children I am trying to load.
Steps to reproduce
- Configure a term set with a term tree depth of more than two
- Use this is the code from the documentation, modified to go one level deeper (plus a few extra try/catches):
var termSet = await termGroup.Sets.GetByIdAsync(spField.TermSetId.ToString());
await termSet.LoadAsync(p => p.Terms);
foreach (var term in termSet.Terms.AsRequested())
{
// Load the child terms of this term
try
{
await term.LoadAsync(p => p.Terms);
foreach (var childTerm in term.Terms.AsRequested())
{
try
{
// New load to get the grandchildren
await childTerm.LoadAsync(p => p.Terms);
foreach (var grandchildTerm in childTerm.Terms.AsRequested())
{
// Do something with the term
;
}
// Do something with the term
}
catch
{
;
}
}
}
catch
{
;
}
// Do something with the term
}This line:
await childTerm.LoadAsync(p => p.Terms);fails every time, with the above exception, regardless of whether childTerm actually has children or not.
Expected behavior
Using the sample code from the documentation to traverse a TermSet, I expect to be able to traverse a nested term set for as many levels as it goes.
Environment details (development & target environment)
- SDK version: [ 1.6.0 ]
- OS: [Windows 10]
- SDK used in: [ Function app ]
- Framework: [ .NET Core v3.1 ]
- Browser(s): [ N/A ]
- Tooling: [ Visual Studio 2022 ]
Additional context
There is a workaround. If I re-load the child term using this:
ITerm childTerm2 = await termSet.Terms.GetByIdAsync(childTerm.Id);I can then get its child terms with:
await childTerm2.LoadAsync(p => p.Terms);Metadata
Metadata
Assignees
Labels
area: model 📐Related to the core SDK modelsRelated to the core SDK modelsbugSomething isn't workingSomething isn't working