web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Restricting calendar i...
Power Apps
Answered

Restricting calendar in book a room template

(0) ShareShare
ReportReport
Posted on by 31

Hi,

 

I am trying to modify book a room template to meet our organization requirement. Is there any option to restrict the room booking either from 9 am to 4 pm or 10 am to 5 PM. Start time should be either 9 am or 10 and end time should be either 4 pm or 5 pm. Will anyone be able to help me to achieve this? 

 

@v-siky-msft

Categories:
  • Joel CustomerEffective Profile Picture
    3,224 on at

    On start of the app it defines a collection with the times. Simply update this to restrict to just the times you want.

     

    see @PowerAddict response here https://powerusers.microsoft.com/t5/Building-Power-Apps/Room-Booking-App-Template/m-p/400044#M117147

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @mtr_windows ,

    Could you please share a bit more about your scenario?

    Do you want to restrict the Start time Dropdown box to be either 9 am or 10 am, and the End time Dropdown box to be either 4 pm or 5 pm?

     

    Actually, the date time options filled within the Start time Dropdown box or End time Dropdown box is based on the Times collection which is initialized within the OnStart property of App. So if you want to restrict the Start time Dropdown box to be either 9 am or 10 am, and the End time Dropdown box to be either 4 pm or 5 pm, you need to make some changes to the Times collection in OnStart property of App.

     

    I have made a test on my side, please take a try with the following workaround:

    Modify the ClearCollect(Times, ...) formula in the OnStart property of App as below:

    1.JPG

    ....
    Concurrent( 
     ClearCollect(RoomsLists, Office365.GetRoomLists().value);
     If(CountRows(RoomsLists) <= 1,
     Set(NoRoomsList, true); 
     ClearCollect(AllRooms, Office365.GetRooms().value);
     Set(AllRoomsConnector, Concat(AllRooms, Address & ";")),
     Set(NoRoomsList, false)
     ),
     ClearCollect(Durations, {Time: "30 min", Minutes: 30}, {Time: "1 hr", Minutes: 60}, {Time: "1.5 hrs", Minutes: 90}, {Time: "2 hrs", Minutes: 120}, {Time: "3 hrs", Minutes: 180}, {Time: "4 hrs", Minutes: 240}),
     // Modify formula below
     ClearCollect(Times, {Text: "9:00 am", Minutes: 540}, {Text: "10:00 am", Minutes: 600}, {Text: "4:00 pm", Minutes: 960}, {Text: "5:00 pm", Minutes: 1020}),
    
     ....
    )

    Then go to the "AdjustDateScreen" of your Template app, then set the Items property of the DropdownStartTime to following:

    Filter(Times, Minutes < 720)

    set the Items property of the DropdownEndTime to following:

    Filter(
     Times, 
     If(
     DropdownStartTime.Selected.Minutes = 540,
     Minutes = 960,
     DropdownStartTime.Selected.Minutes = 600,
     Minutes = 1020
     )
    )

    Then remove the formula within the Default property of the DropdownEndTime.

    2.JPG

     

    Please try above solution, then check if the issue is solved.

     

    Best regards,

  • mtr_windows Profile Picture
    31 on at

    Hi @ v-xida-msft

     

    I have changed the OnStart property of App and made changes on AdjustDateScreen. I can see only 9 am and 10 am as start time and 4 pm and 5 pm as end time. But save option is grayed out even after selecting the start and end time. I have attached the screenshot. Can you help me to fix this?

    Book a room template.JPG
  • mtr_windows Profile Picture
    31 on at

    Hi @v-xida-msft 

     

    I am using phone version of the application. I guess you have made the changes in tablet version. Is there anything else I need to change in phone version?

  • mtr_windows Profile Picture
    31 on at

    Hi @jlindstrom 

     

    I have tried this solution too. But getting same error. At booking page I am getting error as start time should be greater than end time

     

     

  • Joel CustomerEffective Profile Picture
    3,224 on at

    Please read through the recommended topics that show related to this thread--this question has been asked and answered many times.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @mtr_windows ,

    Do you set your template app as Phone Layout?

     

    I have also made a test on my side, and don't have the issue that you mentioned. The screenshot as below:

    1.JPG

    Please make sure you have modified your Times collection formula within the OnStart property of App as below:

    ClearCollect(Times, {Text: "9:00 am", Minutes: 540}, {Text: "10:00 am", Minutes: 600}, {Text: "4:00 pm", Minutes: 960}, {Text: "5:00 pm", Minutes: 1020})

    DropdownStartTime.Items:

    Filter(Times, Minutes < 720)

    DropdownEndTime.Items:

    Filter(
     Times, 
     If(
     DropdownStartTime.Selected.Minutes = 540,
     Minutes = 960,
     DropdownStartTime.Selected.Minutes = 600,
     Minutes = 1020
     )
    )

    then remove the formula within the Default property of the DropdownEndTime.

     

    I have attached my sample app below, please open it directly on your side, then check if the issue is fixed.

     

    Regards,

  • mtr_windows Profile Picture
    31 on at

    Hi @v-xida-msft 

     

    Thanks a lot for sharing the template. It is working perfectly fine without any issue. Once again thanks a lot for providing the quick solution and helped me to meet the deadline.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard