cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrNigel
Level 8

Incrementing to Monday if DueDate = Sat or Sun

This is a simple requirement that is failing on the final step when I try and add 'n' days to the DueDate variable.  The Flow is simple:

 

  1. Create a task
  2. Set task DueDate to utc(now) + 2 days using 'Get Future Time'
  3. Use dayOfWeek and Switch to add either 2 or 1 days to DueDate if dayOfWeek=6 or 0

All this logic works fine, but I get this error when I try and add either 2 or 1 days to DueDate:

 

Flow save failed with code 'WorkflowRunActionInputsInvalidProperty' and message 'The inputs of workflow run action 'Set_variable_4' of type 'SetVariable' are not valid. Self reference is not supported when updating the value of variable 'DueDate'.'.

 

I am using this expression to update DueDate in a Set Variable action:

 

formatDateTime(addDays(variables('DueDate'),1),'dd-MMMM-yyyy')
 
What action/expression should I be using to add 2 or 1 days to DueDate?
 
TIA community 🙂
 
 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Incrementing to Monday if DueDate = Sat or Sun

Hi @MrNigel 

 

Believe you are doing the format expression 'formatDateTime(addDays(variables('DueDate'),1),'dd-MMMM-yyyy')' under the variables('DueDate'). Flow won't support this. 

 

What you could do is use a compose action set and use the output value for the next flow step. Another way to do is declare another variable and use the format expression.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

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!



View solution in original post

3 REPLIES 3
Super User
Super User

Re: Incrementing to Monday if DueDate = Sat or Sun

Hi @MrNigel 

 

Believe you are doing the format expression 'formatDateTime(addDays(variables('DueDate'),1),'dd-MMMM-yyyy')' under the variables('DueDate'). Flow won't support this. 

 

What you could do is use a compose action set and use the output value for the next flow step. Another way to do is declare another variable and use the format expression.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

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!



View solution in original post

Dual Super User
Dual Super User

Re: Incrementing to Monday if DueDate = Sat or Sun

Hi @MrNigel 

 

use expressions

if( equals(dayOfWeek(addDays(utcNow(),1)),'5'),addDays(utcNow(),3),if( equals(dayOfWeek(addDays(utcNow(),1)),'6'),addDays(utcNow(),2),addDays(utcNow(),1)))
 
replace utcnow() - with your date field value
 
above expression
will check if dayofweek is 5- friday - it will bypass weekend and go to monday - by adding 3 days
if dayofweek is 6 -saturday - it will bypass sunday and go to monday - by adding 2 days
else it will add 1 day
 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

MrNigel
Level 8

Re: Incrementing to Monday if DueDate = Sat or Sun

@abm You were correct, I needed to use the Condition action. The flow goes like this:
 
  1. Use GetFutureTime to add 2 days to DueDate
  2. Use Switch to branch based on DayOfWeek
  3. If DayOfWeek=6 use Condition to add 2 days so DayOfWeek=1
  4. Condition expression is: formatDateTime(addDays(variables('DueDate'),2),'yyyy-MM-dd')

 

SatSunSolution.PNG

 

 
I know I could do this with less actions, but by repeating stuff it makes it easier for the person maintaining the Flow after I have gone to understand the logic.
 
@RezaDorrani your solution is also correct, but I am an old school workflow guy (Staffware in the 80s/90s, then e-work, Skelta, K2, Nintex) and I like to have very descriptive process maps so the person who maintains the flow doesn't need to be an expression guru 😉

Thank you both for solving my issue,
 
Nigel

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 190 members 5,304 guests
Please welcome our newest community members: