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

Limit the number of items entry per day

I have a SharePoint list for programming gas fuel calendar. Users need to schedule when they need the card by pick a day from a date column. Look very simple but,  I need to set a condition that for every date the maximum entry is limited to 3 . with other words no more than 3 people can take a gas card per day.  For example :

 

Add one item for date first of the month. This date can be pick second time, third time, but when somebody wants to pick this date for the four time it will be block or receive some message to pick another day. Can this be achieved using PowerApps?

If you need further information please tell me.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ciprianpopovici,

Have you solved your problem?

Do you want to validate the card booking to make it limit to 3?

Could you please share a bit more about your scenario?

I have a test on my side, please take a try as below.

Set the OnSelect property as below:

If(
    With(// I use With() to deal with the delegation warning messgae.
        {
            ds: Filter(
                Product, // Here replace with your data source name
                Date = DatePicker8_1.SelectedDate
            )
        },
        CountRows(ds)
    ) >= 3,
    Notify(
        "pick another day",
        NotificationType.Error
    ),
    SubmitForm(Form2) // Replace with your form name
)

Please check if this could help you at some degree.

 

Best Regards,
Qi

View solution in original post

6 REPLIES 6
zmansuri
Super User
Super User

You put a button to check weather the date is available or not, You can also put this code directly on submit button.

Button OnClik

Set(varCount,CountRows(Filter(ListName,DateColumn=DatePicker.SelectedDate)));

This variable will compare user's selected date and compare it against your list entries. then find the matching entries and count rows. Let's say there are three entries matching to the selected date. 3 will be stored in varCount.

 

Then next line:

If(varCount>=3,Notify("Please Choose another Date",NotificationType.Error),Submit Code);

 

This will check your variable if it is greater then or equal to 3 it will display error message if not it will submit your data.

ciprianpopovici
Helper II
Helper II

Hello, Thank you. I will test and come back with feedback.

 

Hi @ciprianpopovici,

Have you solved your problem?

Do you want to validate the card booking to make it limit to 3?

Could you please share a bit more about your scenario?

I have a test on my side, please take a try as below.

Set the OnSelect property as below:

If(
    With(// I use With() to deal with the delegation warning messgae.
        {
            ds: Filter(
                Product, // Here replace with your data source name
                Date = DatePicker8_1.SelectedDate
            )
        },
        CountRows(ds)
    ) >= 3,
    Notify(
        "pick another day",
        NotificationType.Error
    ),
    SubmitForm(Form2) // Replace with your form name
)

Please check if this could help you at some degree.

 

Best Regards,
Qi

Hello,

Sorry for my late response. Today i tested the solution proposed by you and @zmansuri , and both are working fine. Both of you are great. Thanks.

 

I will use your solution because  it's avoiding delegation so will accept as a solution.

 

Thanks again.

Thanks for the  code provided. It's  working super fine.  I will use the code provided by @v-qiaqi-msft because avoid delegation warning.

All the best.

Another way to get rid of delegation warnings is not to use CountRows. Just use Count instead.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,380)