cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Check if time on submit is smaller than a certain time + other constraint

So I have to make a lunch app in PowerApps, the app is created from a Sharepoint list.

Now there are some time restrictions I have to deal with, so this is the case:

 

-The employees can order a sandwich before 9:45 AM the same day and;

-The rest of the day they can order for any other day of the year

 

So I assume I have to do the check on the OnSelect of the Submit button but I can't really figure out the exact formula to get it right.

Anyone have other ideas? Please let me know because this is a crucial part of the app. All help will be appreciated.

 

Time_Restriction.PNGThis is what I tried: If(DataCardValue6 < TimeValue("9:45"),SubmitForm(EditForm1),DataCardValue6.SelectedDate > Today(),SubmitForm(EditForm1),ErrorKind.Conflict)

Also how do I show the error message after?

 

 Kind regards

 

Tom





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Level 10

Re: Check if time on submit is smaller than a certain time + other constraint

PS However, I would do it another way.

 

I would use exactly the same conditions, but would set the Disabled property of the submit button/icon instead.

Hence Disabled to this:

Not(DataCardValue6.SelectedDate > Today() ||
(IsToday(DataCardValue6.SelectedDate) &&
(Hour(Now())<9 || (Hour(Now())=9 && Minute(Now())<=45)))
 )

And OnSelect to this:

SubmitForm(EditForm1)

View solution in original post

7 REPLIES 7
Meneghino
Level 10

Re: Check if time on submit is smaller than a certain time + other constraint

Hi @Tom_Slosse

 

Please try this:

 

If(DataCardValue6.SelectedDate > Today() ||
(IsToday(DataCardValue6.SelectedDate) &&
(Hour(Now())<9 || (Hour(Now())=9 && Minute(Now())<=45)))
 ,
SubmitForm(EditForm1)
)

Basically the submit form action will only happen if the conditions are met, if not, then nothing happens.

Meneghino
Level 10

Re: Check if time on submit is smaller than a certain time + other constraint

PS However, I would do it another way.

 

I would use exactly the same conditions, but would set the Disabled property of the submit button/icon instead.

Hence Disabled to this:

Not(DataCardValue6.SelectedDate > Today() ||
(IsToday(DataCardValue6.SelectedDate) &&
(Hour(Now())<9 || (Hour(Now())=9 && Minute(Now())<=45)))
 )

And OnSelect to this:

SubmitForm(EditForm1)

View solution in original post

Super User
Super User

Re: Check if time on submit is smaller than a certain time + other constraint

Meneghino

 

Thanks for the quick reply!!!

I would love to test your solution but my lookup field for code gives an error: The lookup service call failed: An error occured on the server.

 

Ill try to fix it asap and will let you know if it works

 

Kind regards

 

 

Tom





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





Super User
Super User

Re: Check if time on submit is smaller than a certain time + other constraint

@Meneghino

 

I made a record in my SharePoint list and there is something strange happening.

If you fill in the form in SharePoint there is no problem, but if you start up the powerapp and refresh your records

then you see in the record that the date isn't correct. It takes the date of yesterday instead.

 

SP_Date.PNGPA_Date.PNG

Could it be that I should check first on IsToday and then on the next day?

 

Kind regards

 

Tom





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





Meneghino
Level 10

Re: Check if time on submit is smaller than a certain time + other constraint

Hi @Tom_Slosse

 

The issue is related to the way dates are treated by different systems in different time zones.  Your SharePoint server is probably in a different time zone from you, or the date is written to SharePoint in UTC but then SharePoint treates this as local, or viceversa. All very messy.

 

In brief, I would strongly recommend to store dates as yyyy-mm-dd text in a text column, that you can then parse when needed.

 

Otherwise you always have to worry about time zones.

 

Here is one post from me:

https://powerusers.microsoft.com/t5/PowerApps-Forum/Please-help-with-UTC/m-p/21244

 

And many many more....

https://powerusers.microsoft.com/t5/forums/searchpage/tab/message?filter=location&location=category%...

Meneghino
Level 10

Re: Check if time on submit is smaller than a certain time + other constraint

PS The fact that you set a column to date only in SharePoint or is many other database systems does not help.  This is because it does not display the time portion, but this lives on in the database, creating the issues you and others see.

Super User
Super User

Re: Check if time on submit is smaller than a certain time + other constraint

@Meneghino

 

Thanks for the tip but the weird thing is that it worked in another app with the same layout (testapp of my lunch). Only displaying date en it shows perfectly in the powerapp as it should it is only with this app it freaks out.

 

TestApp_Date.PNGTestApp_PA_Dae.PNG

 

So its weird it doesnt work properly anymore.

 

Kind Regards

 

 

Tom





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 102 members 5,377 guests
Please welcome our newest community members: