This post will demonstrate how you can apply REST Filtering in Power Automate apps.
Our Power Automate app to date has a design that emails us a custom email for every document within our document library at a regular interval. This Blog post will show you how modify this app’s design so we only receive email notifications for the latest uploaded documents.
Our current Power Automate app contains the following REST query: /_api/web/lists/getbytitle(‘Documents’)/items
This query will bring back all the items in our Document Library. We need to modify this query in order to filter out unwanted items. We can achieve this using the REST query filter syntax – see further REST query syntax here.
To bring back documents created after the 26th of March 2016 we would use the REST query: /_api/web/lists/getbytitle(‘Documents’)/items?$filter=Created ge datetime’2016-03-26T00:00:01Z’
However, you probably require our filter to use a date that is related to the frequency that our Power Automate app is run. For example, if the app is run daily we would like the filter to be the last 24 hours (i.e. no less than 1 day from now). We can achieve this by adding a Power Automate dynamic expression in place of the xxxxx text in: /_api/web/lists/getbytitle(‘Documents’)/items?$filter=Created ge datetime’xxxxx’
The dynamic expression for no less than 1 day from now would be : addDays(utcNow(),-1). This expression can be added using Power Automate using the “Date and time” expressions are shown in the screenshot below.
This post demonstrated how to perform REST Filtering in Power Automate to reduce the number of email notifications you receive. However, we may wish to receive just one email that summarises what documents have been uploaded since the last time your Power Automate app was run. How you can go about producing this summary email is the topic of my next Blog post.