This article aims to explain some issues and how to resolve them on common tasks when working with SharePoint files in Power Automate such as creating a new file, querying document libraries, and deleting files.
these tasks seem to be easy to implement using the existing actions under the SharePoint category in Power Automate but as soon as we start using them, we face some annoying errors.
To query the content of a document library and search for a file with a specific name using Power Automate, the following expression needs to be added to the “Get Files” action as shown in the following screenshot:
As can be seen in the above screenshot the following expression has been used to filter the files that are returned from the “Get Files” action:
FileLeafRef eq ''
For example, to find all files that contain “Test” in their name the expression needs to be:
FileLeafRef eq 'Test'
Or if only a specific extension such as docx is needed the expression needs to be:
FileLeafRef eq '.docx'
To have multiple conditions in the filter query, the conditions can be combined using the ‘and’ or ‘or’ operators like:
FileLeafRef eq '.docx' or FileLeafRef eq '.doc'
Similarly, to query the files that are older than 7 days, the following filter query can be used:
Created le ‘[date in DD-MM-YYYY format]’
Created le ’22-02-2022’
Please note that “le” means less than or equal to and “lt” means less than.