Filter Query Date Modified GT than

Brass Contributor

Morning.

I created a flow to send email notifications to all users when files are added to the company's library.

The email is to go out every day at 5:30pm and include a list of all the files that were added since the last email. But i am clearly doing something wrong, because the same notification goes out 2 days in a row (so if i add files today to the library, i will receive a notification today at 5:30pm and again tomorrow at 5:30pm)

 

I used a filter query - modified gt 'formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd')'

 

Not sure what expression to use to make it work.

 

Thank you

 

2 Replies

@MVCuser 

To resolve the issue where the same notification is sent two days in a row, you can modify the filter query expression in your Power Automate flow. Here's a suggested modification:

1. Open your Power Automate flow and locate the action that retrieves the files added to the library.

2. Edit the filter query expression to compare the modified date against the last sent notification timestamp. You can achieve this by storing the last sent notification timestamp in a variable or in a SharePoint list column.

Example:
- Assume you have a variable named `LastNotificationSentTime` that holds the last sent notification timestamp.
- Modify the filter query expression to compare the modified date against `LastNotificationSentTime`:

modified gt 'formatDateTime(variables('LastNotificationSentTime'), 'yyyy-MM-ddTHH:mm:ssZ')'

Note: Adjust the format of `LastNotificationSentTime` to match the expected date and time format in your filter query.

3. After retrieving the files, update the `LastNotificationSentTime` variable or SharePoint list column with the current timestamp to mark the time of the latest sent notification.

Example:
- Set the `LastNotificationSentTime` variable to the current timestamp using the expression:

formatDateTime(utcNow(), 'yyyy-MM-ddTHH:mm:ssZ')

By comparing the modified date of the files against the `LastNotificationSentTime`, you ensure that only files modified after the previous notification are included in the current notification. This prevents duplicate notifications for the same files.

 

Make sure to save and test your modified Power Automate flow to ensure that it sends notifications correctly and avoids duplications based on the modified date comparison.

 

If I have answered your question, please mark your post as Solved
If you like my response, please give it a like
Hi @Deleted
thank you for this solution.
Unfortunately my knowledge of PA is not that advanced and I honestly don't know how to get the Last notification Stamp. I am working with several libraries at a time (using parallel actions) so i have several get files (property only) and then it is all connected with a compose and create HTML table.
the fields that i have available are those that are part of the library.
In order to get a Last notification column on those libraries, i guess i will have to get that added somehow with another flow?
thanks again