0

We are doing a POC on Power Apps with a trial version and we have developed a room booking app in Model-Driven App under Power Apps. If the User has booked any room and another user tries to book a room for the same date, it should not allow. It is an essential validation for any booking system but unable to find a way to achieve the same in Power Apps

For example: - If a user booked a room in Delhi from 1st to 5th Jan. Other users should not be allowed to book this room for the above dates. Another user books the same room for 1st Jan to 4th Jan then it should not allow but we have not found any feature in the model-driven app to restrict the entry of this record.

Does anyone know how to proceed?

enter image description here

1 Answers1

0

This is a high level answer given the lack of specifics in your question. When the user selects a time, you should add the following to your OnSelect event of the gallery or button (whatever you use to let the user select the room).

//Refresh the datasource
Refresh(YourDatasource);

// Filter the data source looking for other events in this room
UpdateContext({RoomEvents,Filter(YourDataSource, RoomID=selectedRoom,Date=SelectedDate)});

// check if there are any items in RoomEvents. If there are, then the room is no longer available
if(RowCount(RoomEvents)>0,Notify("This room is no longer available",NotificationType.Error))

Again, this high level, but should get you going in the right direction. You should do something similar when displaying the list of rooms in the first place, filtering out rooms that are not available.

Robbert
  • 6,481
  • 5
  • 35
  • 61
  • Thanks for your reply, when we are trying to applying an event on a form or any control then In the properties window it is saying: “You don't have any library files”. There is an option to add a library. When I am going on that then there are multiple libraries is there. I am new to Power Apps and looking around to see what can be done with it. Please can you suggest which library I can use for handling the event? – honey mittal Feb 02 '21 at 08:16
  • @honeymittal, are you using the web version of PowerApps or a desktop version? I am not familiar with the panel you showed in your screenshot. The event I described in my answer is for the OnSelect or OnChange event of a button or gallery. – Robbert Feb 02 '21 at 16:16
  • I am working on the web version of Power Apps to create a Model-Driven App. This panel will be opened as : Power Apps Login -> Solution - > Table/Entity -> Forms -> Edit Main form type. As well as in model-driven app , I have not found any button to add, I have seen this option to add button in canvas app but in model-driven app it will automatically add save and delete button on-page. This form will manipulate based on the columns of the table. Please suggest what can I do in this situation? – honey mittal Feb 03 '21 at 07:02
  • I'm not familiar with Model driven solutions. Sorry. – Robbert Feb 03 '21 at 15:46