May 18 2021 12:41 AM
Hi all,
I've search everywhere and I cannot seem to find an answer to my question.
I have a document library (Not a list) on my sharepoint site and I'd like to set up a flow to notify me if there are items Expiring at any point in the next 7 days.
I've got the flow to remind me x days before an item expires, but I want to extend this to search all items and if there are any items that will be expiring in the next 7 days(so if it expires on Days, 1,2,3,4,5,6 or 7) to email me a list of those items.
I know the solution will be very simple, but it has eluded me so far.
For reference, my Document library has a column called (Expiry Date) and using a list to store the documents is not is not suitable for our use case.
Any help would be enormously appreciated.
May 18 2021 05:02 AM - edited May 18 2021 06:55 AM
Solution@Tom_By yes you can do this using an array variable as shown in the screenshots below. In my Documents library there are 4 documents that are due for review in the next 7 days:
The flow runs at 13.00 every day and the first action is to initialize an array variable. When doing date comparisons you need to have the date format as yyyy-MM-dd. So next we add 2 compose controls, one for today's date and one for the date 7 days ahead and format them a shown:
Next, add a get files (properties only) action. But we only want to bring those items back from the library where the NextReview date is greater than or equal to the ComposeToday and less than or equal to the Compose7Days. So in the Filter Query field add NextReview ge '{output of the ComposeToday}' and NextReview le '{output of the Compose7days}'
So that we can have them in order in the email we add NextReview into the Order By field:
Next, add an Apply to each and select value from the dynamic content. I want to convert the NextReview date back to UK format but you might not need these next steps: inside the apply to each add a compose control and add the NextReview column. Then add another compose and format it as shown.
Next add an append to array variable and add the name and review date - I've used the output from the ComposeFormatDate compose for this:
Next, - outside the apply to each - if you want to you can add a create html table action and add the array.
Finally send the email and use the output from the create html table action.
The email looks as shown below. It is possible to add another compose action to add formatting to the table but I've not done that on this occasion.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
May 18 2021 07:16 AM
I think this suggestion will work, however I am encountering an error when inputting my details into the filter Query - "Column 'NextReviewDate' does not exist. It may have been deleted by another user..."
I've tried Inserting _x0020_ between words with no success. Also tried copying the column title exactly as it appears in column editor, with no joy either.
I cant check if everything else works as its getting stuck and failing early on.
Any ideas?
May 18 2021 07:21 AM
@Tom_By go to library settings and select the column. Then in the address bar look at the end at what the Field= is, that's what you need to have in the flow.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
May 18 2021 07:30 AM
May 18 2021 07:56 AM - edited May 18 2021 11:46 PM
You'll need to post screenshots of your flow. However the issue appears to b e with the column name. If you have renamed the column that doesn't rename the internal name. That's why I suggested going to the column settings and copying the internal name of the column after Field=
May 20 2021 05:01 AM
Jul 19 2023 07:50 AM
Jul 19 2023 08:19 AM
@oroberts55 you can format the html table by adding the following CSS inside a compose action, changing it to taste:
You can copy the CSS from the spoiler below:
Then use the outputs of that compose in your email. Becauase I've also included a company logo in the email I have turned on the code view </> button and added html tags to the email
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
Jul 19 2023 08:23 AM
Jul 19 2023 08:35 AM
Worked a treat, thanks! I'm only testing at the moment, I get this:
Is there a way to format the dates so that they show as dd/mm/yyyy?
And how do I change the font?
Thanks again 🙂
Jul 19 2023 11:35 AM
Jul 20 2023 01:19 AM
Sorry, my bad, turns out I hadn't followed the instructoins properly and was just pulling through Expiry Date from the file properties - I've changed it now and it works perfectly.
Final question (for now) - how can I change the font of the table so that it matches the rest of the email please? Again, probably very simple for someone who knows what they're doing!
Jul 20 2023 05:02 AM
Jul 25 2023 07:13 AM
I have everything working as it should, thanks again for your help so far.
I am getting a daily email, but often this is blank as there are no files that are due to expire - I was wondering if there is a way of only sending the email if necessary? i.e. if there are no items that are due to expire then no email is sent?
Jul 27 2023 03:31 PM
Jul 27 2023 08:11 PM
Jul 27 2023 08:11 PM
Aug 08 2023 06:34 AM
Jan 16 2024 10:23 AM
Hello, for me the array is not bring all documents inside the due date window only one of them, I reviewed all the workflow and found nothing....
May 18 2021 05:02 AM - edited May 18 2021 06:55 AM
Solution@Tom_By yes you can do this using an array variable as shown in the screenshots below. In my Documents library there are 4 documents that are due for review in the next 7 days:
The flow runs at 13.00 every day and the first action is to initialize an array variable. When doing date comparisons you need to have the date format as yyyy-MM-dd. So next we add 2 compose controls, one for today's date and one for the date 7 days ahead and format them a shown:
Next, add a get files (properties only) action. But we only want to bring those items back from the library where the NextReview date is greater than or equal to the ComposeToday and less than or equal to the Compose7Days. So in the Filter Query field add NextReview ge '{output of the ComposeToday}' and NextReview le '{output of the Compose7days}'
So that we can have them in order in the email we add NextReview into the Order By field:
Next, add an Apply to each and select value from the dynamic content. I want to convert the NextReview date back to UK format but you might not need these next steps: inside the apply to each add a compose control and add the NextReview column. Then add another compose and format it as shown.
Next add an append to array variable and add the name and review date - I've used the output from the ComposeFormatDate compose for this:
Next, - outside the apply to each - if you want to you can add a create html table action and add the array.
Finally send the email and use the output from the create html table action.
The email looks as shown below. It is possible to add another compose action to add formatting to the table but I've not done that on this occasion.
Rob
Los Gallardos
Microsoft Power Automate Community Super User