cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ashj100
Frequent Visitor

prevent duplicated reservation

Hello everyone, 

 

I was trying to edit this code https://github.com/IAmTheWebb/Powerapps-DeskReservation 

I found that if I booked for example on 12/7/2022 and rebook on the same date it accept the booking like it doesn't prevent duplicated reserv for the same date!

I need to fix this to make sure that the employees doesn't reserv same room at the same date and time 

Any advise on what can I do so I fix it? I'm completely new to power app  😞 

 

ashj100_0-1656792784208.png

 

3 REPLIES 3
Drrickryp
Super User
Super User

@ashj100 

To prevent the user from submitting a duplicate item, you can disable the Submit button.  In the DisplayMode property of the button that submits your form, The following assumes that the control holding the DeskText information is called txtDeskText and the control with the Check out from is a datepicker called chkoutDatePicker.  (you can replace these in the formula with the actual control names in the form. 

With(
    {deskres:AddColumns(
                  'Desk Reservations',"deskdate",  
                                       DeskText & Text('Check Out From',ShortDate
                                                  )
               )
    },
    If(
        Concatenate(
                  txtDesk.Text,chkoutDatePicker.SelectedDate
        )in deskres.deskdate , DisplayMode.Disabled,Edit
    )
 )

You could also use the error message control in the check out datepicker card to display a message

With(
    {deskres:AddColumns(
                  'Desk Reservations',"deskdate",  
                                       DeskText & Text('Check Out From',ShortDate
                                                  )
               )
    },
    If(
        Concatenate(
                  txtDesk.Text,chkoutDatePicker.SelectedDate
        )in deskres.deskdate ,"There is already a reservation for this date"
    )
)

 

 

this will only work with the same person who reserved this date and time. 

I want to prevent all users from boking if this date has been reserved before by someone else? 

Set(
selectedDate,
Calendar_1.StartDate
);
Set(
selectedEndDate,
Calendar_1.EndDate
);
Set(
startTime,
DateTimeValue(
Text(
selectedDate,
DateTimeFormat.ShortDate
) & " " & ddTimeFrom.Selected.Value
)
);
Set(
endTime,
If(
DateValue(
Text(
selectedEndDate,
DateTimeFormat.ShortDate
)
) < DateValue(
Text(
selectedDate,
DateTimeFormat.ShortDate
)
),
DateTimeValue(
Text(
selectedDate,
DateTimeFormat.ShortDate
) & " " & ddTimeTo.Selected.Value
),
DateTimeValue(
Text(
selectedEndDate,
DateTimeFormat.ShortDate
) & " " & ddTimeTo.Selected.Value
)
)
);
If(
IsEmpty(startTime) && IsEmpty(endTime),
Notify(
"You must select a date and time to continue",
NotificationType.Warning
),
Navigate(DeskSelect)
)

 

 

Drrickryp
Super User
Super User

@ashj100 

I don't see why that would be true as the added column does not contain user specific information. The principle is to create a column by combining just enough information to identify a duplicate and prevent the user from submitting it.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,799)