cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Book parking / reservation app

Hi all, 

 

That's my very first PowerApps creation today, And I have an issue (if it is ;))

 

So my need : 

Create an app to allow employees to book parking - Only 10 cars can use this parking per day. 

 

What I do: 

I created a SP list with a "name" column and a "reservation date" column

 

On PowerApps, I have my form with two questions (from the SP list), and I added a personalize field with a button on it to validate (cf picture) the form.

 

But now... I don't know how to create the function to say, if we already have 10 registrations for a specific day, we can't submit form anymore with text message "Not available"... I'v tried something like that without success... 

If(CountIf('Reservation parking AIX';DataCardValue13.SelectedDate='Reservation parking AIX')=6;false;EditForm(Form2))

 

I really hope that you can help 😉

 

Many thanks, 

Bastien

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @bastienO ,

 

I think that your notification should appear before you select the button "Je Book". That's why it's better to move your logic / verification on OnChange property of the DatePicker control.

The function CountIf unfortunatelly cannot be delegated to Sharepoint (that's why you received a yellow sign warning, it gives a sign of not very good coding 🙂), and for this reason I propose the following solution (where YourDateColumn is your real name of the date column):

If(
CountRows(
Filter(
            GroupBy('Reservation parking IX';'YourDateColumn';'Result');
             'YourDateColumn' = DataCardValue13.SelectedDate)
)>9;
Notify("No more spaces available on that date");;UpdateContext({disableButton:true});
UpdateContext({disableButton:false})

I hope that you saw that Iintroduced a context variable - boolean called disableButton, which is thought to control the displaymode property of button (it's necessary to avoid accidental submit form after notify text dissapeared). So DisplayMode of Button control should look like this:

If (disableButton,DisplayMode.Disabled,DisplayMode.Edit)

OnVisible Screen -> OnStart insert the following code to initialize the disableButton variable:

UpdateContext({disableButton:false}

And last, set OnSelect property of the Button to:

             Submit(Form2)

I notice that you use the european way for writting code, that's why i'm not 100% sure about syntax (; vs. ;; and " vs ' ).

 

Hope it helps !

View solution in original post

5 REPLIES 5
Resolver II
Resolver II

You're absolutely on the right track with that CountIf(). It looks like you aren't specifying the column to compare to the SelectedDate. The CountIf would look like this:

 

CountIf('Reservation parking AIX'; 'DateColumnFromDataSource' = DataCardValue13.SelectedDate)

 

And then you can use the Notify() function to have a banner telling the user "no more spaces available" Like this:

If(CountIf('Reservation parking AIX'; 'DateColumnFromDataSource' = DataCardValue13.SelectedDate) = 10; Notify("No more spaces available on that date"))

 

 

Hi @bastienO ,

 

I think that your notification should appear before you select the button "Je Book". That's why it's better to move your logic / verification on OnChange property of the DatePicker control.

The function CountIf unfortunatelly cannot be delegated to Sharepoint (that's why you received a yellow sign warning, it gives a sign of not very good coding 🙂), and for this reason I propose the following solution (where YourDateColumn is your real name of the date column):

If(
CountRows(
Filter(
            GroupBy('Reservation parking IX';'YourDateColumn';'Result');
             'YourDateColumn' = DataCardValue13.SelectedDate)
)>9;
Notify("No more spaces available on that date");;UpdateContext({disableButton:true});
UpdateContext({disableButton:false})

I hope that you saw that Iintroduced a context variable - boolean called disableButton, which is thought to control the displaymode property of button (it's necessary to avoid accidental submit form after notify text dissapeared). So DisplayMode of Button control should look like this:

If (disableButton,DisplayMode.Disabled,DisplayMode.Edit)

OnVisible Screen -> OnStart insert the following code to initialize the disableButton variable:

UpdateContext({disableButton:false}

And last, set OnSelect property of the Button to:

             Submit(Form2)

I notice that you use the european way for writting code, that's why i'm not 100% sure about syntax (; vs. ;; and " vs ' ).

 

Hope it helps !

View solution in original post

Many thanks 😉

Many thanks 🙂

Hi @bastienO ,

If one of the answers satisfy your request, please don't forget to accepted it as a solution.

 

Thank you !

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Users online (7,099)