cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User III
Super User III

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

Power Automate Video Tutorials

View solution in original post

3 REPLIES 3
Super User III
Super User III

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

Power Automate Video Tutorials

View solution in original post

Dual Super User II
Dual Super User II

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

@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
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (82,224)