cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Help with first flow

Hello! I am struggling with my frist flow and decided to stop lurking and post in hopes I can get some guidance on how to accomplish these requirements.

 

I have a sharepoint list for vacation requests and when an employee puts in a vacation request, the first part of flow should notice the item creation, validate the list item that it abides by the rules listed below.

 

1. Two weeks notice required

2. Nobody else has vacation on the Sharepoint list during the same period.

 

If none of these rules are violated, add to the vacation shared calendar.

 

If a rule is violated, send approval email to manager with approve or deny. Based on response, add to calendar and send confirmation email to employee if approved. If denied, change the sharepoint list submission to show the denied response to the list item.

 

If the sharepoint list is modified repeat the process to ensure rules are still being passed correctly and resend approval email if rule violated. Modify calendar event as well including removal if the sharepoint list item is deleted.

 

All that being said, I have been able to send approval emails based on the templates included as well as create a calendar item from the sharepoint list. I have made validation rules using infopath 2013 for 2 weeks notice requirement but validation from my experience thus far prevents data from being submitted which isn't what I want. Just an approval email to be triggered.

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Help with first flow

Hi @soundwave123,

 

Thanks for posting.

For the rules.

The first one is easy to configure under Microsoft Flow, what we need to do is to use the Adddays function with UTCnow() to compare with the StartTime of the Vacation, 

 

lessOrEquals(Adddays(utcnow(),14,'yyyyMMdd'), formatDateTime(StartTime,'yyyyMMdd'))

 

 

If Adddays(utcnow(),14,'yyyyMMdd') is less than formatDateTime(StartTime,'yyyyMMdd'), then the rule is meet, otherwise, send the approval.

For second rule, which is a little hard to deal with.

First we need to use Sharepoint ->Get items Action, then use the Filter Array action, Under the filter array action condition, compare the Start/End time with the one from the trigger.

Here we use StartTime1, EndTime1 to represent the value from the Get items data, and StartTime, EndTime to represent the value for newly created item,

The logic to check if there are poeple have vocation in the same time range should be:

Or( 

    StartTime<=StartTime1<EndTime,

    StartTime<EndTime1<=EndTime

)

Switch to Formula, it should be:

 

Or(
   And(LessOrEquals(StartTime, StartTime1),
          Less(StartTime1,EndTime)
         ),
   And(Less(StartTime, EndTime1),
          LessOrEquals(EndTime1, EndTime)
         )
)

After the Filter Array action, if we would like to check if there is anyone have the same vocation requests, we could check if the Filter Array Action is empty, if empty, then the rule is meet.

 

Formula should be:

Empty(Body('Filter_Array'))

So the final condition to check, should be:

@And(
lessOrEquals(Adddays(utcnow(),14,'yyyyMMdd'), formatDateTime(StartTime,'yyyyMMdd')),
Empty(Body('Filter_Array'))
)

For the corresponding Action, please add it to the Yes or No part accordingly.

Post back if you have any further questions.

 

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Regular Visitor

Re: Help with first flow

I'm not sure where to put the formulas in the flow. Actions/Triggers/Conditions? I am super new to this so I apologize for not having a better base knowledge.

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Kudoed Authors
Users online (8,281)