Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Limit number of bookings

(0) ShareShare
ReportReport
Posted on by

Hi all,

 

I have a Book button to book a desk.

How to limit number of bookings (total 1 or total 2) during the day?

kinghnvn_0-1640055560172.png

@StalinPonnusamy 

 

Categories:
  • kinghnvn Profile Picture
    on at
    Re: Limit number of bookings

    Hi @AJ_Z 

     

    I just noticed that @StalinPonnusamy has popped in to offer assistance reply @AJ_Z to me if you still need me 🙂 . But i am sure he is able to assist. -> My question is open for everyone ^^. thank you so much, I'm still need your help.

     

    Step Two: change the label's Visible property to: CountRows(Filter(Datasource,User.Email = User().Email && RelatedDate Today()))>=2

    -> I have tried your code as below

     

    CountRows
    (Filter
    (Datasource,
    Employee.Email = UserInfo.Email &&
    DateValue(Text(selectedEndDate,DateTimeFormat.ShortDate)) = FromDate)) < 1

     

    but I'm getting the message:

     

    Delegation warning. The highlighted part of this formula might not work correctly on large date sets. The "CountRows" operation is not supported by this connector.

  • kinghnvn Profile Picture
    on at
    Re: Limit number of bookings

    For First, you can combine your current code like -> Yes, I'm using the same the code

     

    If
    (
    !IsBlank(LookUp(DeskBooking,Employee.Email = UserInfo.Email && MySlotTime)), DisplayMode.Disabled,
    !IsBlank(LookUp(DeskBooking,MySlotTime && Title = MainGallery.Selected.Title)), DisplayMode.Disabled
    )

     

    For Second, I have tried to use the code but it's not working

     

    Behavior function in a non-behavior property. You can't use this propert to change values elsewhere in the app.

    Delegation warning. The highlighted part of this formula might not work correctly on large data sets. The "CountRows" operation is not supported by this connector.
    The function 'If' has some invalid arguments.

    --

     

    The Book button / Visible:

     

    UpdateContext({IsMorethan2Bookings : false});
    ForAll(DateDiff(Calendar_1.StartDate, Calendar_1.EndDate),
    If(CountRows(
    Filter(OfficeBooking_1,
    Employee.Email = UserInfo.Email && FromDate = DateAdd(Calendar_1.StartDate, ThisRecord.Value,Days)
    )) >= 2,UpdateContext({IsMorethan2Bookings : true});
    ) //If
    ); //ForAll

    If(IsMorethan2Bookings, Notify("You can't book more than two desks in single day"),
    Patch(.....)
    )

     

    kinghnvn_0-1640242610182.pngkinghnvn_1-1640242687959.png

     

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at
    Re: Limit number of bookings

    I just noticed that @StalinPonnusamy has popped in to offer assistance reply @AJ_Z  to me if you still need me 🙂 . But i am sure he is able to assist.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at
    Re: Limit number of bookings

    Is this a displaymode if statement for a different reason or for the same issue. if it is for a different thing i know just where to insert our bit but if you are attempting to resolve the same thing we will likely just need to replace it 🙂 . Also is MySlotTime a column in the datasource and is it date only or date and time if so or is it some other data type. This will help me understand the situation so we can adapt my suggestion 🙂

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    Re: Limit number of bookings

    Hi @kinghnvn 

     

    First, you can combine your current code like

    If(
    !IsBlank(LookUp(DeskBooking,Employee.Email = UserInfo.Email && MySlotTime)) ||
    !IsBlank(LookUp(DeskBooking,MySlotTime && Title = MainGallery.Selected.Title)),
    DisplayMode.Disabled,DisplayMode.Edit
    )

     

    Second, You are using Calander control which has a Date Range so Changing your current display mode may be challenging since we need to loop through the selected dates to check each date.

     

    So, We need to validate this logic on the "OnSelect" of the Book button.

     

    Logic concept

    • Declare a local variable to false
    • Loop through the Calander Dates
    • Get each single date
    • Get the Booking count for each day
    • If any one of the days is more than 2 then set the variable to true
    • Finally, verify No days has more than 2
      • If Yes through the message or display Label
      • If No then Patch or Save
    UpdateContext({IsMorethan2Bookings : false});
    
    ForAll(DateDiff(Calander1.StartDate, Calander1.EndDate),
    If(CountRows(
    Filter(OfficeBooking, 
    EmployeePerson.Email = UserInfo.Email && BookingDate = DateAdd(Calander1.StartDate, ThisRecord.Value,Days)
    )) >= 2,UpdateContext({IsMorethan2Bookings : true});
    ) //If
    ); //ForAll
    
    If(IsMorethan2Bookings, Notify("You can't book more than two desks in single day"),
    Patch(.....)
    )


    Thanks,
    Stalin - Learn To Illuminate

      

  • kinghnvn Profile Picture
    on at
    Re: Limit number of bookings

    I'm using DisplayMode for the Button as below.

    How to combine your code?

     

    If(
    !IsBlank(
    LookUp(
    DeskBooking,
    Employee.Email = UserInfo.Email && MySlotTime
    )
    ),
    DisplayMode.Disabled,
    !IsBlank(
    LookUp(
    DeskBooking,
    MySlotTime && Title = MainGallery.Selected.Title
    )
    ),
    DisplayMode.Disabled
    )

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at
    Re: Limit number of bookings

    I would do this utilising DisplayMode for the button, a Label for user journey and a countrows with a filter.
    Step One: change the button's DisplayMode to If(CountRows(Filter(Datasource,User.Email = User().Email && RelatedDate = Today()))>=2, DisplayMode.Disabled,DisplayMode.Edit)

    Step Two: change the label's Visible property to: CountRows(Filter(Datasource,User.Email = User().Email && RelatedDate = Today()))>=2

    Step Three: change the label's text to something like. "You cannot Book more than Two Desks in one Day"

    Ensure you tweak my formula to matchup with your datasource  an situation. everything in red probably needs to be changed the blue part for Today() may need to change if they are using a dataselector to book for the future.


    If you need more help on how to apply this to your circumstance please provide the name of the Datasource and the column name / column type referencing who booked it. Then also let me know how they are picking the day is it a DataSelector or always Today()

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard