I have a Patch() function that create 1 parent 'Reservation' record, and multiple child 'Reservation Details' records, and it skips weekends and a collection of holiday dates.
When I am executed Patch() function in Editing mode, both 'Reservation and 'Reservation Details' records were created on the correct days (weekdays).
However, when the app is published, 'Reservation Details' records created there was incorrect (1 day behind).
Scenario
- FromDate_Datepicker : Mon (05 Feb 2024)
- ToDate_Datepicker = Sun (11 Feb 2024)
| | 05 Feb | 06 Feb | 07 Feb | 08 Feb | 09 Feb | 10 Feb | 11 Feb |
| | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
| Editing Mode | Created | Created | Created | Created | Created | Skipped | Skipped |
| Published Mode | Skipped | Created | Created | Created | Created | Created | Skipped |
| Published Mode is 1 day behind | *Sun | *Mon | *Tue | *Wed | *Thu | *Fri | *Sat |
Based on the results above, Published Mode is 1 day behind Editing Mode.
Question: May I know how can I resolve this, and is a code change to fix this possible?
Thank you.
_____________________________________________________________________________________
Below is my full Patch() function:
//Creates 1x parent 'Reservation' record
If(
BookingType_Self_Cb.Checked,
ClearCollect(
ReservationRecord,
Patch(
Reservations,
Defaults(Reservations),
{
'Start Date': FromDate_Dp.Value,
'End Date': ToDate_Dp.Value,
'Reserved For': 'Reserved For (Reservations)'.Employee,
Facility: Building_Ddl.Selected,
Area: Area_Ddl.Selected,
'Employee Name': Self_Section_EmployeeName_Ddl.Selected,
'Reserved Desk': Self_Section_Seat_Ddl.Selected,
'Booked By': Self_Section_EmployeeName_Ddl.Selected
}
)
)
);
// Store created parent 'Reservation' record in a variable 'newReservationRecord'
Set(
newReservationRecord,
First(ReservationRecord)
);
//Create 'Reservation Details' record for each date and associated it with 'Reservation' record created by 'Reservation Details'.'Reservation'
//Only create records if date matches weekdayt dates in WeekdayDates collection
Patch(
'Reservation Details',
ForAll(
Sequence(
DateDiff(
FromDate_Dp.Value,
ToDate_Dp.Value,
TimeUnit.Days
) + 1
),
With(
{
_Date: DateAdd(
FromDate_Dp.Value,
Value - 1,
TimeUnit.Days
)
},
If(
_Date in WeekdayDates,
{
Date: _Date,
Reservation: newReservationRecord,
Name: newReservationRecord.'Reservation ID' & "_" & _Date,
'Reserved Desk': newReservationRecord.'Reserved Desk'
}
)
)
)
);
- 'Reservations'.'Start Date' is correct
- 'Reservations'.'End Date' is correct
- 'Reservation Details'.'Date' is wrong