Skip to main content

Power App Hotel Room Booking App example. Get a room!



Edited 26.8.23: Link to data sample create SharePoint lists Link to download
                          App sample Link to download

****
 Since it does not look like we will have any nice summer holiday this year, I'd decided to fantasise about booking a room. How sad is that! lol


A quick app, filters the available rooms for the required period, and Book Room button submits the booking form.


Video demonstrates app in action. 

Formulae also visible, but I will add logic formulae below as well( I am  skipping formatting formulae)




App OnStart 

Set(varDate,1)


txtvarDays

Default 

varDays

On Change 

Set(varDays, Value(txtvarDays.Text))

allows manually enter amount of days / nights


Icon Arrow Up Day+

OnSelect 

Set(varDays, varDays+1)


Icon Arrow Down Day-

OnSelect 

If(varDays>1,Set(varDays, varDays-1)) // does not go below 1


Find Room Button

Refresh(Bookings);ClearCollect(colDates,ForAll(Sequence(DateDiff(txtDateFrom.SelectedDate,txtDateTo.SelectedDate)),DateAdd(txtDateFrom.SelectedDate, Value)));


ClearCollect(colRoomBooked,Filter(Bookings,

('Date From'>=txtDateFrom.SelectedDate &&'Date To'<txtDateTo.SelectedDate)||//with in selected range

'Date To'>txtDateFrom.SelectedDate&&'Date To'<txtDateTo.SelectedDate||//Starts before, and finish before or at "To" date

'Date From'<txtDateTo.SelectedDate&&'Date To'>=txtDateTo.SelectedDate ||// Starts after "From" 

'Date From'<txtDateFrom.SelectedDate &&'Date To'>txtDateTo.SelectedDate).RoomID);//Overlap

ClearCollect(colRoom,Filter(Rooms,Status.Value="Available"));RemoveIf(colRoom, ID=Blank());

RemoveIf(colRoom, ID in colRoomBooked)



galRoom

Items colRoom


Reset Button

OnSelect 

Set(varDays,1);Clear(colRoom);Clear(colRoomBooked)

Book Room Button

OnSelect SubmitForm(frmBooking)


frmBooking 

OnSuccess 

Set(varDays,1);Clear(colRoom);Clear(colRoomBooked);ResetForm(frmBooking)

Check In Date

OnChange

Clear(colRoom);Clear(colRoomBooked)

Default Date

Today()


Check Out Date

Default Date txtDateFrom.SelectedDate+varDays

DisplayMode  View

txtRoom  (Form Item Look Up Column)
Items
Filter(Choices([@Bookings].Room),Value<>"") // not really relevant, as I changed it to View mode any way

Default Selected Items
Filter(Choices([@Bookings].Room),Value<>""&&Id=galRoom.Selected.ID)
DisplayMode  View


What also you cannot see is a hidden field txtRoomID. It is a number field in my List and the default value is an Id of selected Room control  txtRoom.Selected.Id

I use this RoomID further when filtering the DataSource for booked rooms and then remove these rooms from all Rooms, which have "Available" Status. (See Find Room Button)


Thanks for reading


If you wish to say thank you please donate to the charity I use to work for.

Donate here

Comments

  1. Can u please help with all the process from sratch how to start with it becoz i need the exact think for my project

    ReplyDelete
    Replies
    1. Hi Vishwas, I am very sorry, too busy at the moment to describe step by step, but I have downloaded the copy of my app and added the data sample in separate excel. (see edited part of the post with the links). I am not sure if it will work for you or not as it is connected to my SharePoint. Have a try. Hopefully you be able to reconnect it. I have not used others apps in the past so cannot advise how to connect it

      Delete

Post a Comment