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

Enhancement: Add fields and filters to 'spo folder list' #4659

Closed
martinlingstuyl opened this issue Mar 17, 2023 · 3 comments
Closed

Enhancement: Add fields and filters to 'spo folder list' #4659

martinlingstuyl opened this issue Mar 17, 2023 · 3 comments
Assignees
Milestone

Comments

@martinlingstuyl
Copy link
Contributor

martinlingstuyl commented Mar 17, 2023

The spo listitem list has some useful features that are not available on spo folder list

As a user, I want to:

  • be able to select specific fields
  • be able to use filters
    (additional: - request folders in a library that contains more than 5000 items)

We need the following options to make this work:

Option Description
--fields [fields] Comma-separated list of fields to retrieve. Will retrieve all fields if not specified and json output is requested.
--filter [filter] OData filter to use to query the list of items with.

Additional Information

The /folders endpoint has NO nextlink/skiptoken implementation like with listitems. We can implement paging though, using $top and $skip. This is a less solid implementation of paging, but useful nonetheless.

To be able to query all items we also have to refactor the endpoint that is used and move from the current $expand setup to using /folders.

The following steps should be taken:

  1. Query GetFolderByServerRelativePath(decodedurl='<folder>')?$expand=Properties&$select=Properties/vti_x005f_folderitemcount,Properties/vti_x005f_foldersubfolderitemcount on the root folder that is coming in through the options.

  2. Next, use GetFolderByServerRelativePath('somefolder')/Folders endpoint to query all folders directly below, with $skip and $top. (Default $take to 5000) Use the Properties to calculate how many calls you need to do here.

  3. When the recursive flag is set, restart step 1-2 on every subfolder coming in from the /Folders calls.

Important: Use the --filter option value for all /Folders calls.

When the --fields option includes values with a /, for example: ListItemAllFields/Id, an additional $expand query parameter should be included on ListItemAllFields.

When the --fields option includes values with a /, for example: ListItemAllFields/Id, an additional $expand query parameter should be included on ListItemAllFields.

Originally posted by @martinlingstuyl in #4654

Additional change: just like with spo listitem list, the spo folder list command now supports retrieving the ID of the listitem. This can be problematic in PowerShell when using the ConvertFrom-Json commandlet, because the ListItemAllFields object has an Id and ID property that are the same except the casing. PowerShell can't handle this. Just like with spo listitem list, we've implemented this to remove the ID property if it is available.

@martinlingstuyl martinlingstuyl changed the title The [spo listitem list](https://pnp.github.io/cli-microsoft365/cmd/spo/listitem/listitem-list/) has some useful features that are not available on [spo file list](https://pnp.github.io/cli-microsoft365/cmd/spo/file/file-list/) The [spo listitem list](https://pnp.github.io/cli-microsoft365/cmd/spo/listitem/listitem-list/) has some useful features that are not available on [spo file list](Enhancement: Add fields, filters and paging to 'spo folder list') Mar 17, 2023
@martinlingstuyl martinlingstuyl changed the title The [spo listitem list](https://pnp.github.io/cli-microsoft365/cmd/spo/listitem/listitem-list/) has some useful features that are not available on [spo file list](Enhancement: Add fields, filters and paging to 'spo folder list') Enhancement: Add fields, filters and paging to 'spo folder list') Mar 17, 2023
@nicodecleyre
Copy link
Contributor

I'm interested in doing this one too!

Should we drop pageSize & pageNumber too here since this command also offers the recursive option, @martinlingstuyl?

And also checking for the threshold here by doing a call to GetFolderByServerRelativePath(decodedurl='/sites/Demo/Shared%20Documents')?$expand=Properties&$select=Properties/vti_x005f_folderitemcount,Properties/vti_x005f_foldersubfolderitemcount first?

@martinlingstuyl
Copy link
Contributor Author

Yes, let's drop the paging props here as well and just query everything using skip and top

@martinlingstuyl martinlingstuyl changed the title Enhancement: Add fields, filters and paging to 'spo folder list') Enhancement: Add fields an filters to 'spo folder list') Mar 24, 2023
@martinlingstuyl
Copy link
Contributor Author

I updated the specs

@martinlingstuyl martinlingstuyl changed the title Enhancement: Add fields an filters to 'spo folder list') Enhancement: Add fields an filters to 'spo folder list' Mar 24, 2023
@milanholemans milanholemans changed the title Enhancement: Add fields an filters to 'spo folder list' Enhancement: Add fields and filters to 'spo folder list' Mar 30, 2023
@martinlingstuyl martinlingstuyl added this to the v6.7 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants