💡 Challenge
When working with SharePoint in Power Automate, it’s often necessary to handle files efficiently but it’s not possible to filter by the normal file name.
✅ Solution
Use the FileLeafRef, FileRef, and FileDirRef fields in combination with OData filtering to streamline your SharePoint queries.
🔧 How It’s Done
Here’s how to do it:
- Use FileLeafRef to filter by file name
🔸 Filter by specific file names without the path.
🔸 e.g.,FileLeafRef eq 'document.pdf'
- Use FileRef to filter by full path
🔸 Filter by the full path to a file.
🔸 e.g.,FileRef eq '/sites/demo/Shared Documents/document.pdf'
- Use FileDirRef to filter by directory
🔸 Filter by files within a specific directory.
🔸 e.g.,startswith(FileDirRef, '/sites/demo/Shared Documents')
🎉 Result
Using these OData filters drastically reduces the amount of data returned and results in faster, more efficient query processing, saving time and system resources.
🌟 Key Advantages
🔸 Faster access to desired files
🔸 Minimal data retrieval for maximum efficiency
🔸 Seamless integration with existing SharePoint processes
🎥 Video Tutorial
🛠️ FAQ
1. How do I apply these OData filters in Power Automate?
In the “Get files (properties only)” action, enter your OData filter expression into the Filter Query field to limit results based on FileLeafRef, FileRef, or FileDirRef.
2. Can I combine multiple OData filter conditions?
Yes. Use logical operators like and
or or
in your filter query, for example:
FileLeafRef eq 'document.pdf' and startswith(FileDirRef, '/sites/demo/Shared Documents')
.
3. Are these fields supported in SharePoint on-premises?
OData filtering with FileLeafRef, FileRef, and FileDirRef works in SharePoint Online and on-premises (2013+). Ensure your environment and connector version support OData queries.
Leave a comment