Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnsureAsync - Wrong UniqueId in Followup Queries #1236

Closed
1 task done
randellhodges opened this issue Jul 23, 2023 · 2 comments
Closed
1 task done

EnsureAsync - Wrong UniqueId in Followup Queries #1236

randellhodges opened this issue Jul 23, 2023 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@randellhodges
Copy link

Category

  • Bug

Describe the bug

Let's say I have the following path created in my sharepoint list

/Folder1

Run this code

var folder = await List.RootFolder.EnsureFolderAsync("Folder1/Folder2");
await folder.EnsurePropertiesAsync(f => f.Properties);

The properties loaded are not for "Folder2" but for the last folder that wasn't created, in this case "Folder1".

I verified this by looking at the url in the debugger:

https://URL/sites/SITE/_api/Web/getFolderById('eda92902-5a83-44d8-abcc-466774812d14')?$select=UniqueId%2cProperties&$expand=Properties

eda92902-5a83-44d8-abcc-466774812d14 = Folder1

I did add a debug before the EnsurePropertiesAsync call to look at the UniqueId on folder and it is correct.

If I run the code a second time, everything works (because EnsureFolderAsync didn't create a folder).

I even tried folder.LoadAsync and still had the same issue.

Note: I'm not sure the SharePoint api supports it, but it would be nice to also include the properties to return at the time of creation.

Expected behavior

That the properties load for the folder specified

Environment details (development & target environment)

  • SDK version: 1.10.0
  • OS: Windows 11
  • SDK used in: Web App
  • Framework: NET Core v6
  • Browser(s): Chromium Edge
  • Tooling: Visual Studio 2022
@jansenbe jansenbe self-assigned this Aug 17, 2023
@jansenbe jansenbe added the question Further information is requested label Aug 17, 2023
@jansenbe
Copy link
Contributor

@randellhodges : it's currently not possible to immediately request the folder properties to load, but making a call after works fine. While checking your approach I've found a bug which I'll fix, but with the current bits below works

// Ensure the folder hiararchy
var addedFolder = await parentFolder.EnsureFolderAsync("sub1/sub2/sub3/sub4/sub5");

// Load the properties you need : WORKS
addedFolder = await context.Web.GetFolderByIdAsync(addedFolder.UniqueId, p => p.Properties);

// FAILS today, but will be fixed
await addedFolder.LoadAsync(p => p.Name, p => p.Properties);
await addedFolder.EnsurePropertiesAsync(p => p.Properties);

Thanks for using PnP Core SDK and reporting this.

@jansenbe
Copy link
Contributor

@randellhodges : a fix has been added, with tomorrow's nightly build you'll be able to use the other approaches as well. Will close this issue now, please re-open or create a new one whenever things are still not working for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants