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

Require and Trigger Approval Based on Date Value

Hi all, 

 

I have an app that tracks the hours logged on engineering projects. When an engineer submits their time they spent working on a project, they choose the date, project, task, status, and how many hours they spent on it. I am looking for a way to require an approval when they try to log time on a date that isn't today or yesterday. Basically, if they forget to record hours it needs to be sent to a manager, who will manually approve or reject the hours. 

 

I am currently using this: If(DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1, Notify("if the date entered is more than 1 day in the past, you need an approval", Error),SubmitForm(Form3)) on my submit button to display an error informing users they must get their hours approved, but I would like to be able to make a button appear when this error pops up to allow the user to request an approval. The information on my form should be sent to the appropriate manager, and if approved it should update the SharePoint site that stores these records. 

 

If anyone can help figure out a way to do this, or help with an approval flow, I would greatly appreciate it! 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@Aurora 

I think I would do the design differently.  I would use the Display mode property of the submit button to be Disabled unless the condition was met ie

 

If(
    DateDiff(
              DataCardValue18.SelectedDate, Today() > 1
    ), DisplayMode.Disabled, Edit
)

 

and have the Approval button and a simple label with your error message with their visible properties as

 

DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1

 

The Submit button would then have simply SubmitForm(Form3) but it would not be enabled unless your condition was met.  This would force the user to request approval and not be able to submit the form if your condition was true.

 

View solution in original post

6 REPLIES 6
Drrickryp
Super User
Super User

@Aurora 

You can put your approval button on the screen and set its visible property to 

DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1

This formula resolves to either true or false.

 

@Drrickryp  

That hides the button, but how can I get them to request an approval if the date is outside the acceptable range? 

 

Drrickryp
Super User
Super User

@Aurora 

I think I would do the design differently.  I would use the Display mode property of the submit button to be Disabled unless the condition was met ie

 

If(
    DateDiff(
              DataCardValue18.SelectedDate, Today() > 1
    ), DisplayMode.Disabled, Edit
)

 

and have the Approval button and a simple label with your error message with their visible properties as

 

DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1

 

The Submit button would then have simply SubmitForm(Form3) but it would not be enabled unless your condition was met.  This would force the user to request approval and not be able to submit the form if your condition was true.

 

@Drrickryp 

Engineers need to be able to log time later in case they forget to do it on the day work is performed. The restriction of not being able to enter dates more than a day in the past is in place so they can't make up fake work and so our accounting department has accurate cost information about work performed on projects. I feel like with this solution, the engineers will not be able to submit hours at all if they are trying to log work from the past. (An example would be trying to log worked hours from the previous week) 

 

If they select a date outside the date range condition, submission still needs to be possible, it just needs to be approved first so their manager knows. In my current app, they get the warning but can still submit hours regardless of date. I need to get approvals integrated so everyone is aware of the situation who needs to be.

@Drrickryp 

Or maybe I misunderstand, I will at least give this a try and see what happens 

Aurora
Helper V
Helper V

Capture.PNG

 

@Drrickryp 

I am receiving an error on the formula, any suggestions? 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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