cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jaysonmurray
Level: Power Up

Show Whether or Not A Room is Available

I'm building a basic app that will show if our conference rooms are available or not. The last piece that I'm trying to work out is just a rule on some text where if a meeting is currently scheduled on the calendar and the meeting is happening now, the text will say "Unavailable". The rest of the time, if no meeting is currently happening now, the room will say "Available".

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
shailendra74
Level 8

Re: Show Whether or Not A Room is Available

Hi @jaysonmurray 

 

Here you go...

 

 

I set some sample data onVisible of the screen.  You need to map the same with you data

 

// THIS IF FOR THE START & END TIME DROPDOWN values
UpdateContext({DATEFORMAT:"mm/dd/yyyy",TIMESLOT:["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00",
"08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00",
"22:00","23:00"]});

// ALL CONF ROOM DATA WITH AVAILABILITY. This would be the source to the datatable or Gallery
ClearCollect(collConfRoomsStatus,{ID:1,NAME:"Conf Room 1",AVAILABLE: true },
{ID:2,NAME:"Conf Room 2",AVAILABLE: true },{ID:3,NAME:"Conf Room 3",AVAILABLE: true },
{ID:4,NAME:"Conf Room 4",AVAILABLE: false });

// CONF ROOM BOOKINGS
ClearCollect(collConfRoomBooking,
{ROOMID:1,STARTDATESmiley Very HappyateValue("07/10/2019"),STARTTIME:TimeValue("13:00"),ENDTIME:TimeValue("14:00")},
{ROOMID:1,STARTDATESmiley Very HappyateValue("07/10/2019"),STARTTIME:TimeValue("9:00"),ENDTIME:TimeValue("12:00")},
{ROOMID:3,STARTDATESmiley Very HappyateValue("07/11/2019"),STARTTIME:TimeValue("13:00"),ENDTIME:TimeValue("14:00")})


 

Screenshot 2019-07-19 at 7.20.05 am.png

set Items property of gallery to collConfRoomsStatus. I just put 2 icons and visible only one based on availablility.

 

Visible property is as follows

icoNotAvailable = !ThisItem.AVAILABLE

icoAvailable = ThisItem.AVAILABLE // to book a conf room, code need to be done onSelect of available icon

 

onSelect of "Locate Room"

 

 

// GET THE STATUS OF CONF ROOMS based on BOOKINGS

ClearCollect(collRoomBooked,
Filter(collConfRoomBooking,STARTDATE=DateValue(Text(dpStartDate.SelectedDate,"[$-en-GB]mm/dd/yyyy")), If(TimeValue(ddStartTime.Selected.Value)<TimeValue(Text(STARTTIME,"[$-en-GB]hh:mm")),
If(TimeValue(Text(STARTTIME,"[$-en-GB]hh:mm"))<TimeValue(ddEndTime.Selected.Value), true ,
If(TimeValue(ddEndTime.Selected.Value)<=TimeValue(Text(STARTTIME,"[$-en-GB]hh:mm")), false ,
If(TimeValue(ddEndTime.Selected.Value)>=TimeValue(Text(ENDTIME,"[$-en-GB]hh:mm")), false , true ))),
If(TimeValue(ddStartTime.Selected.Value)<TimeValue(Text(ENDTIME,"[$-en-GB]hh:mm")), true , false ))));
// SET Conf Room status default to true
UpdateIf(collConfRoomsStatus, true ,{AVAILABLE: true });

// Based on above filter change the status to false for conf rooms booked. Other conf rooms are default to true above
ForAll(collRoomBooked,UpdateIf(collConfRoomsStatus,ID=ROOMID,{AVAILABLE: false }))

Thanks.

5 REPLIES 5
shailendra74
Level 8

Re: Show Whether or Not A Room is Available

Hi @jaysonmurray 

 

You need to Filter on the current date & time from the list/table to check if there are any records. If record count > 0 the room is unavailable else available.

 

 

Thanks.

jaysonmurray
Level: Power Up

Re: Show Whether or Not A Room is Available

Thanks for your reply, @shailendra74 !

 

I've been trying to tackle this, but I'm not sure I'm savvy enough to try to figure out how to write this function. I'm pretty new to this game.

 

Any tips would be appreciated!

shailendra74
Level 8

Re: Show Whether or Not A Room is Available

@jaysonmurray 

 

what is the list/table structure which hold the date and time of a conference room

 

Thanks.

jaysonmurray
Level: Power Up

Re: Show Whether or Not A Room is Available

@shailendra74 

 

Table MyCalendarEvents has Start and End columns both formatted as M/D/Y H:M AM/PM as strings, along with other data.

shailendra74
Level 8

Re: Show Whether or Not A Room is Available

Hi @jaysonmurray 

 

Here you go...

 

 

I set some sample data onVisible of the screen.  You need to map the same with you data

 

// THIS IF FOR THE START & END TIME DROPDOWN values
UpdateContext({DATEFORMAT:"mm/dd/yyyy",TIMESLOT:["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00",
"08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00",
"22:00","23:00"]});

// ALL CONF ROOM DATA WITH AVAILABILITY. This would be the source to the datatable or Gallery
ClearCollect(collConfRoomsStatus,{ID:1,NAME:"Conf Room 1",AVAILABLE: true },
{ID:2,NAME:"Conf Room 2",AVAILABLE: true },{ID:3,NAME:"Conf Room 3",AVAILABLE: true },
{ID:4,NAME:"Conf Room 4",AVAILABLE: false });

// CONF ROOM BOOKINGS
ClearCollect(collConfRoomBooking,
{ROOMID:1,STARTDATESmiley Very HappyateValue("07/10/2019"),STARTTIME:TimeValue("13:00"),ENDTIME:TimeValue("14:00")},
{ROOMID:1,STARTDATESmiley Very HappyateValue("07/10/2019"),STARTTIME:TimeValue("9:00"),ENDTIME:TimeValue("12:00")},
{ROOMID:3,STARTDATESmiley Very HappyateValue("07/11/2019"),STARTTIME:TimeValue("13:00"),ENDTIME:TimeValue("14:00")})


 

Screenshot 2019-07-19 at 7.20.05 am.png

set Items property of gallery to collConfRoomsStatus. I just put 2 icons and visible only one based on availablility.

 

Visible property is as follows

icoNotAvailable = !ThisItem.AVAILABLE

icoAvailable = ThisItem.AVAILABLE // to book a conf room, code need to be done onSelect of available icon

 

onSelect of "Locate Room"

 

 

// GET THE STATUS OF CONF ROOMS based on BOOKINGS

ClearCollect(collRoomBooked,
Filter(collConfRoomBooking,STARTDATE=DateValue(Text(dpStartDate.SelectedDate,"[$-en-GB]mm/dd/yyyy")), If(TimeValue(ddStartTime.Selected.Value)<TimeValue(Text(STARTTIME,"[$-en-GB]hh:mm")),
If(TimeValue(Text(STARTTIME,"[$-en-GB]hh:mm"))<TimeValue(ddEndTime.Selected.Value), true ,
If(TimeValue(ddEndTime.Selected.Value)<=TimeValue(Text(STARTTIME,"[$-en-GB]hh:mm")), false ,
If(TimeValue(ddEndTime.Selected.Value)>=TimeValue(Text(ENDTIME,"[$-en-GB]hh:mm")), false , true ))),
If(TimeValue(ddStartTime.Selected.Value)<TimeValue(Text(ENDTIME,"[$-en-GB]hh:mm")), true , false ))));
// SET Conf Room status default to true
UpdateIf(collConfRoomsStatus, true ,{AVAILABLE: true });

// Based on above filter change the status to false for conf rooms booked. Other conf rooms are default to true above
ForAll(collRoomBooked,UpdateIf(collConfRoomsStatus,ID=ROOMID,{AVAILABLE: false }))

Thanks.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 115 members 4,744 guests
Please welcome our newest community members: