The code below gives me the error “Incompatible type. We can’t evaluate your formula because the context variable types are incompatible with the types of values in other places in your app.” in regards to the Set function and ‘foundItem’ record:
If(
IsBlank(conflictingReservation),
// Try to add a new reservation to the 'Equipment Inventory Reservations' list
Set(
PatchResult,
Patch(
Switch(
selectedBranch.BranchLocation,
"Seattle, WA", 'Equipment Inventory Reservations',
"Oakland, CA", 'EIR - Oakland, CA'
// Add more cases here for other branches...
),
Defaults(
Switch(
selectedBranch.BranchLocation,
"Seattle, WA", 'Equipment Inventory Reservations',
"Oakland, CA", 'EIR - Oakland, CA'
// Add more cases here for other branches...
)
),
{
'EquipmentName': foundItem.'EquipmentName',
'ReservedBy': User().FullName,
Email: User().Email,
'ReservationStart': startDateTime,
'ReservationEnd': endDateTime,
'ReservationStartTime': Text(StartTimePicker.Selected.Value, "[$-en-US]hh:mm AM/PM"), // The start time of the reservation
'ReservationEndTime': Text(EndTimePicker.Selected.Value, "[$-en-US]hh:mm AM/PM"), // The end time of the reservation
'ReservationEndDateTime': endDateTime,
'ReminderSent': "No",
Location: globalNukeLocation // Update the 'Location' field
}
)
),
// If there are conflicting reservations, notify the user
Notify(
"The " & foundItem.'EquipmentName' & " is already reserved by " & conflictingReservation.'ReservedBy' & " between " & Text(DateTimeValue(Text(conflictingReservation.'ReservationStart', "[$-en-US]mm/dd/yyyy") & " " & conflictingReservation.'ReservationStartTime'), "[$-en-US]mm/dd/yyyy hh:mm AM/PM") & " and " & Text(DateTimeValue(Text(conflictingReservation.'ReservationEnd', "[$-en-US]mm/dd/yyyy") & " " & conflictingReservation.'ReservationEndTime'), "[$-en-US]mm/dd/yyyy hh:mm AM/PM") & ".",
NotificationType.Error
)
);
This is after I changed:
Set(
PatchResult,
Patch(
'Equipment Inventory Reservations'
To:
Set(
PatchResult,
Patch(
Switch(
selectedBranch.BranchLocation,
"Seattle, WA", 'Equipment Inventory Reservations',
"Oakland, CA", 'EIR - Oakland, CA'
// Add more cases here for other branches...
I tried replacing the switch function with ‘Equipment Inventory’ list and it fixed it. Then I replaced it with the Switch function again and it worked for awhile until it didnt. Is there a way for me to bypass this error by initialized foundItem somewhere, in some way?