cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Steve-O28
New Member

Email reminder for multiple expiry columns

Hi all,

 

I am attempting to build a flow to send reminder emails from a specific email address to a specific email address 30 before expiry date.

 

I have numbered pouches that contain multiple products - each pouch contains the same 8 products with a variety of different expiry dates.

 

So the expiry date for product A in pouch 1 might be different to the expiry date for product A in pouch 5.

 

I have a SharePoint list that is set up as follows:

 

My first column is the pouch number I.e. 1, 2, 3, 4 etc and each subsequent column is the product name I.e. Cheese, Bread, Milk. The expiry dates are then filled into the appropriate box.

 

 

I wish to send an email to a specific email address from a specific email address  30 days before a product is due to expire. I wish the email to say something like:

 

“Cheese is due to expire in 30 days in the following pouches:

1

5

9

 

Bread is due to expire in 30 days in the following pouches:

1

4

6

 

Milk is due….. etc”

 

Here is an image of an example list setup the same as my list

6AD2132C-B5EF-4784-AFA6-740DAFE58BCE.png

thanks for your assistance

1 ACCEPTED SOLUTION

Accepted Solutions
David_MA
Impactful Individual
Impactful Individual

I think I see why dates are not working for you. I just noticed you said you formatted the expression for the Expiration variable to addDays(utcNow(),30,'dd/MM/yyyy'). While your dates can appear in different formats on screen via your site and profile settings, the date stored in SharePoint is actually stored in ISO8601 format. You need to use that format in query filters and other logic in Power Automate. For your Expiration variable, it needs to be formatted as addDays(utcNow(),30,'yyyy-MM-dd')

View solution in original post

7 REPLIES 7
David_MA
Impactful Individual
Impactful Individual

If I accurately understand what you want to do, this is not too complicated. You will use the following actions three times to get each of your product types, and then combine the results into your e-mail:

  • Get items
  • Condition
  • Select
  • Create HTML Table

At a high level, your workflow will look like this:

David_MA_0-1664823222904.png

  • Then initialize a variable named "Expiration", which is a string with the expression addDays(utcNow(),30,'yyyy-MM-dd').
  • You will then use this variable in each get items action to filter the the items to only those that will expire in 30 days:
    David_MA_1-1664823351406.png
  • The condition just checks to make sure it found items that expire, which uses the expression 
    length(outputs('Get_items_Cheese')?['body/value'])
    David_MA_2-1664823436142.png
  • If yes, then use the select statement to get the Pouch values and convert them to an HTML table:
    David_MA_3-1664823498130.png
  • Then put it all together in your e-mail:
    David_MA_4-1664823566759.png

This is the final result:

David_MA_5-1664823613563.png

 

Steve-O28
New Member

Hi David,

 

Thanks for getting back to me so soon.

 

I have tried this and although it sends an email, it does not show the pouch numbers. (See below)

 

Image1.png

 I have my list set up in what I imagine is an identical way with the list title as "Pouch1", columns names "Pouch, Cheese, Milk, Break"

 

Image2.png

 

I have began by just trying to get a single product working and then I can copy the results for the remaining. At the high level this is my flow:

Image3.png

 

and looking within each stage is as follows:

Image4.png

 

Image5.png

 Image6.png

 

Initialize variable Expiration does output a date 30 days in future (03/11/2022)

 

The expressions are as follows for each stage:

Initialize variable Expiration: 

addDays(utcNow(),30,'dd/MM/yyyy')
 
Condition:
length(outputs('Get_items_Cheese')?['body/value'])
 
Select From: Value
outputs('Get_items_Cheese')?['body/value']
 
Map: item()?['Title']
 
Create HTML table
From:
body('select')
 
Although the flow runs it appears to fail to return pouch numbers somewhere in the Get items Cheese stage or the condition stage as the expression result is false
 
Image7.png

 

I believe it is because the product column in the list is formatted as a date and time. When I set the column formatting to single line of text it returns the pouch numbers correctly.
 
Is there a method of making this work with the columns set to date and time?
 
thanks again
David_MA
Impactful Individual
Impactful Individual

It could be a couple of things; however, you definitely want your fields with the dates to be date/time columns, but you don't need to store the time.

  1. The first thing is to make sure you have items in your list that would be 30 days from today. Depending on your date format in your list, to me it looks like you don't if the dates showing in your screen shot are in the format mm/dd/yyyy. Thirty days from today would be November 3 at least in North America.
  2. The next thing is that you may not have the correct field name in your filter query. The filter query uses the internal name of the field. You can get this by going into your list settings and clicking on the field. Then look at the end of the URL and it will show the internal name of the field. For example, the display name of the field below is External Contractor, but the internal name is:
    David_MA_0-1664893701619.png

     

The example list above I have dates for the "Cheese" column set as 02/11/2022, 03/11/2022 and 04/11/2022 (UK date format) dd/MM/yyyy

 

In the filter query I had been using the name as describes from the URL.

 

When I set the cheese column as Date and Time it returns no pouch number. Change the column to single line of text it returns the pouch number correctly. It just appears to be the column formatting that makes it work / not work.

David_MA
Impactful Individual
Impactful Individual

Glad you got it working!

just to clarify - it doesnt work with the column set to date and time, but does for single line of text.

 

I can work with it as single line of text but would be cleaner if set to date and time

David_MA
Impactful Individual
Impactful Individual

I think I see why dates are not working for you. I just noticed you said you formatted the expression for the Expiration variable to addDays(utcNow(),30,'dd/MM/yyyy'). While your dates can appear in different formats on screen via your site and profile settings, the date stored in SharePoint is actually stored in ISO8601 format. You need to use that format in query filters and other logic in Power Automate. For your Expiration variable, it needs to be formatted as addDays(utcNow(),30,'yyyy-MM-dd')

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,172)