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 😞
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)
)
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.
User | Count |
---|---|
251 | |
102 | |
94 | |
47 | |
37 |