cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Aurora
Helper V
Helper V

How to require an approval based on date

Hi all, 

 

I have an app I have been working on that tracks the hours an employee spend on an engineering project. When they submit their work hours, they first select the date the work was performed on. I am wondering if it would be possible to create a rule that basically says "if the date entered is more than 1 day in the past, require an approval". I would like to use approvals in teams for this process, am unsure of which properties I need to change in my date picker. 

 

Any help is greatly appreciated!

9 REPLIES 9
StalinPonnusamy
Super User
Super User

Hi @Aurora 

 

For user notification. Set the OnChange property of Date Picker to

If(DateDiff(DateValue1.SelectedDate, Today(),Days) > 1, Notify("if the date entered is more than 1 day in the past, require an approval"))

 

Create a Power automate/Flow when the record is modified with approvals.

Aurora
Helper V
Helper V

Do I need to create the flow first? I'm using: If(DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1, Notify("if the date entered is more than 1 day in the past, require an approval")) and it isn't returning an error message when I submit the form with a date outside of my desired boundary. 

@StalinPonnusamy 

I tried editing the mormula to:

If(DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1, Notify("if the date entered is more than 1 day in the past, require an approval", Error))

But I'm still not getting a notification

StalinPonnusamy
Super User
Super User

 Hi @Aurora 

 

If you are looking for user notification on submit button then Set the OnSelect command of Submit button to

 

If(DateDiff(DateValue1.SelectedDate,Today(),Days)>1,Notify("if the date entered is more than 1 day in the past, require an approval",Error),SubmitForm(EditForm1))

 

Note: Change fields names 

Aurora
Helper V
Helper V

@StalinPonnusamy 

 

Works great, I'll make sure to accept it as a solution. Do you know if there is a way to automatically make a button to appear after the error message popped up to request an approval, or would this been done in power automate? 

StalinPonnusamy
Super User
Super User

Hi @Aurora

 

The previous command will not submit the form. It just throws the user notification. Looks like still, the form needs to submit after the user notification. In this case

 

Set the OnSelect property of Submit button to

 

If(DateDiff(DateValue1.SelectedDate,Today(),Days)>1,Notify("if the date entered is more than 1 day in the past, require an approval",Error));SubmitForm(EditForm1)

 

 

Create Power Automate to send approval if that date difference is more than 1 day.

 

Let me know if any help needs it to create Power Automate.

Aurora
Helper V
Helper V

@StalinPonnusamy 

 

I could use some help with power automate. I initially selected a template named "Click PowerApps button to start approval of SharePoint items and send email" because I would like the flow to start when a button is pressed, however I am not sure if I can integrate teams into this template. 

 

I imagine the app like this: If a user selects a date that is unacceptable, the error message listed above occurs. Once that error occurs, a new button appears before the user that allows the to request an approval for there hours. I would like the button to be hidden unless the need to request an approval, and I would like the approvals to be handled in Microsoft teams. The approval will allow a SharePoint site to be updated. 

 

I appreciate any help! 

StalinPonnusamy
Super User
Super User

Hi @Aurora

 

I assume you have 2 buttons (SubmitButton and SubmitForApprovalButton). Only one button will be visible at any time based on date selection.

  • Set the SubmitButton Visible property to
DateDiff(DateValue1.SelectedDate,Today(),Days)<=1
  • Set visible property of SubmitForApprovalButton to
!SubmitButton.Visible
  •  Set OnSelect property of SubmitForApprovalButton to
Notify("if the date entered is more than 1 day in the past, require an approval",Error);SubmitForm(EditForm1)

 

StalinPonnusamy_0-1632194551673.png

StalinPonnusamy_1-1632194564314.png

 

 

StalinPonnusamy
Super User
Super User

Hi @Aurora 

 

Please let us know if anything needs on your post. We can help with this.


Please do not forget to give kudos if you find the suggestion helpful or Accept it as a solution if works fine to help other users to find it useful.

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,142)