cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TWolsten
Helper III
Helper III

Dynamic email subject depending on the due date

Hi all,

 

I am trying to change the Subject in the email that gets sent out dynamically depending on whether any of their actions have gone overdue.

 

The email takes a Created HTML table to combine all actions into a singular email so some might be within the due date and others might be overdue, I am trying to flag the email subject to 'URGENT: You have actions overdue!' if one of the actions is overdue.

 

I have currently wrote:
if(greaterOrEquals(length(less(formatDateTime(body('Create_HTML_table')?['Due'],'yyyy-MM-dd'), formatDateTime(utcNow(),'yyyy-MM-dd'),1)),1), 'URGENT: You have actions overdue!', 'Actions Outstanding')

 

into the subject line but it doesn't like it.

 

Any ideas what I could be doing wrong?

 

Thanks in advance.

 
 
1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for the reply abm.

 

In the end I used another filter on the array I had to look for Overdue actions:

 

Then I just used the array to check if it was empty or not:

if(empty(body('Filter_array_3')),'ACTIONS Outstanding','URGENT - You have OVERDUE actions')
 
That seems to have done the trick.
 
Thanks for the help and pushing me in the right direction!

View solution in original post

12 REPLIES 12
abm
Super User
Super User

Hi @TWolsten 

 

The less() expression returns true or false. The I can see you are checking the length of the boolean value which is going to fail the flow.  I would say please split into compose action steps for each and check what you are getting from the run history. This way its easy to debug the values. Also once its all working you can use as a single expression. 

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Thanks for the reply.

 

It seems to be failing to find the Due field in my Create HTML table:

 

InvalidTemplate. Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '0' and column '0': 'The template language expression 'if(less(formatDateTime(body('Create_HTML_table')?['Due'],'yyyy-MM-dd'), formatDateTime(utcNow(),'yyyy-MM-dd'),1), 'URGENT: You have actions overdue!', 'Actions Outstanding')' cannot be evaluated because property 'Due' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.

 

I thought it could be because it is an array of multiple items within the HTML table but all I am wanting to do is scan through all the items in the array and if one of them is Overdue then change the title of the email, do you think this is possible?

Hi @TWolsten 

 

Need to see your flow and a sample data. Could you post a screenshot and some data?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
TWolsten
Helper III
Helper III

TWolsten_0-1652874149167.png

TWolsten_1-1652874157170.png

 

 

In regards to to the data, the only thing I am using in the formula is the 'Due' column which is a date field and I am wanting to pass an If statement to determine if the title of the email should be either:

  • 'URGENT: You have actions overdue!'
  • 'Actions Outstanding'

 

The rest of the flow (prior to the formula) gathers all individuals who have actions and sends out individual emails to them

TWolsten_0-1652877679629.png

 

TWolsten_1-1652877679639.png

 

 

 

In regards to to the data, the only thing I am using in the formula is the 'Due' column which is a date field and I am wanting to pass an If statement to determine if the title of the email should be either:

  • 'URGENT: You have actions overdue!'
  • 'Actions Outstanding'

 

The rest of the flow (prior to the formula) gathers all individuals who have actions and sends out individual emails to them

Hi @TWolsten 

 

Thanks for the screenshot.

 

The error you are getting is "cannot be evaluated because property 'Due' cannot be selected. Property selection is not supported on values of type 'String'"

 

Could you add a compose action step above the email action step and map

 

body('Create_HTML_table')?['Due']

 

Check the run history and see what value its returning?

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Fails again:

 

InvalidTemplate. Unable to process template language expressions in action 'Compose_2' inputs at line '0' and column '0': 'The template language expression 'body('Create_HTML_table')?['Due']' cannot be evaluated because property 'Due' cannot be selected. Property selection is not supported on values of type 'String'.

Hi @TWolsten 

 

Check the run history of Create HTML table. Believe this is an array. You cannot use the property like that.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Correct it is an array, so if I wanted to skim through all the values is there a way to do that? Then say if the count of any of the items is greater than or equal to 1 then show one title and if it is less than 1 then show the other?

Any ideas on this please?

Hi @TWolsten 

 

image.png

 

After filter array 2 Add an Apply to Each Loop action step. Add the body('Filter_array_2') under the apply to each to iterate. Inside the loop you can access the properties like this.

 

item()?['Due']

 

Thanks

 

body('')?['Due']

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Thanks for the reply abm.

 

In the end I used another filter on the array I had to look for Overdue actions:

 

Then I just used the array to check if it was empty or not:

if(empty(body('Filter_array_3')),'ACTIONS Outstanding','URGENT - You have OVERDUE actions')
 
That seems to have done the trick.
 
Thanks for the help and pushing me in the right direction!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,995)