1

I am working on a new web part to display a list of files in a SharePoint document library called Medicine files. I want users to be able to filter the files based on different columns, including file names. I am using PnPjs to search for files by name, and it works perfectly for other columns, but not for the file name. Here's my current code:

 await sp.web.lists.getByTitle("Medicine files").items.filter("FileLeafRef eq 'test.pdf'").expand("File").orderBy("Created", asc)();

When I use the Name column, I get the following error:

Column 'Name' does not exist. It may have been deleted by another user.

And when I use the FileLeafRef property, I get this error:

The attempted operation is prohibited because it exceeds the list view threshold.

I have tried different column names, such as Name, DisplayName, FileLeafRef, LinkFilenameNoMenu, LinkFilename, and BaseName without success. I have also checked the column name in the column settings, and it is defined as Name.

Any suggestions to help me resolve this issue would be greatly appreciated!

1 Answers1

0

try

await sp.web.lists.getByTitle("Medicine files").items.filter("FileLeafRef eq 'test.pdf'").expand("File").orderBy("Created", asc).getAll();

refer pnp.github.io for details.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 05 '23 at 14:37
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34638979) – sanitizedUser Jul 10 '23 at 00:40