cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ciprianpopovici
Helper II
Helper II

Deny add items after specific hour

Hello

We have an app for adding food orders. Users add every day food orders. Orders must be taken everyday by 10 am . After this hour they cannot order and must receive an message when they try to add a new item.

It's that possible in PowerApps?

Thank you

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @ciprianpopovici,

Have you solved your problem?

Do you want to deny order after 10 am everyday?

Could you please if there is need to re-trigger the order after 24:00?

 

I agree with @zmansuri that you could use the Hour() function to get the hour number with 24 hour format. However, if you just want to deny order from 10:00 to 24:00 and re-order by 10:00 next day, I think you should add something different.

 

If(
    Hour(Now()) > 10 && Hour(Now()) <= 24,
    Notify(
        "No order after 10:00 am!",
        Error
    ),
    Patch(
        Product,
        {Title: "NewItem"}
    )// Here replace with your Patch() formula
)

Hope this could help you at some degree.

Best Regards,
Qi

View solution in original post

ciprianpopovici
Helper II
Helper II

I think i managed to find a solution. The first formula was wrong.

I add a new formula that seems to work in tests

 

If(Hour(Now())<10,"OK hour",If(And(Hour(Now())=10,Minute(Now())<30),"OK Minute","NO"))

View solution in original post

4 REPLIES 4
zmansuri
Super User
Super User

On your submit code write this:

 

If(Hour(Now())>10,Notify("Order can not be placed after 10:00 A.M.",NotificationType.Error),"Your Submit Code")

 

This code Hour(Now()) gives hour as number in 24 hour format. for eg. if it's 3 in the afternoon output will be 15. So, click on the submit button will first check if it's past 10 AM. if it is true it will display above message in the error form. If it is false it will add item

v-qiaqi-msft
Community Support
Community Support

Hi @ciprianpopovici,

Have you solved your problem?

Do you want to deny order after 10 am everyday?

Could you please if there is need to re-trigger the order after 24:00?

 

I agree with @zmansuri that you could use the Hour() function to get the hour number with 24 hour format. However, if you just want to deny order from 10:00 to 24:00 and re-order by 10:00 next day, I think you should add something different.

 

If(
    Hour(Now()) > 10 && Hour(Now()) <= 24,
    Notify(
        "No order after 10:00 am!",
        Error
    ),
    Patch(
        Product,
        {Title: "NewItem"}
    )// Here replace with your Patch() formula
)

Hope this could help you at some degree.

Best Regards,
Qi

hello, Sorry for my late response . Thank you for the support. I have  little modification on the formula , I try to find why not working, but no luck. So i need to block adding items if the hours is later than 10.30 AM. I have to use minutes also.  I use this formula , but all the time a have return false, even if hour it's 10.20 or 10.15... I adapt the formula in Excel and in Excel it's working. Can you give a clue?

 

And(And(Hour(Now())>=10,Hour(Now()<11)),Minute(Now()<30))

ciprianpopovici
Helper II
Helper II

I think i managed to find a solution. The first formula was wrong.

I add a new formula that seems to work in tests

 

If(Hour(Now())<10,"OK hour",If(And(Hour(Now())=10,Minute(Now())<30),"OK Minute","NO"))

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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