cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate V
Advocate V

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
Highlighted
Super User III
Super User III

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!

Learn more from my blog

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

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!

Learn more from my blog

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

Highlighted
Advocate V
Advocate V

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
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,389)