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

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.

 

View solution in original post

@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 IV
Helper IV

Capture.PNG

 

@Drrickryp 

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,547)