0

I am creating a desk reservation app and use the code below to see if the chosen desk is available, but get a delegation warning for using Not and In. I know that the reservation list will have more than 2,000 records (changed from the default 500). Initially I thought a For loop might work only to find there is not such thing in PowerApps. Is there a workaround?

Filter(
    Desks,
    Not (DeskID in Filter(
        DeskReservations,
        ReservationStartTime <= DeskReservedFrom && ReservationEndTime >= DeskReservedTo || 
        ReservationEndTime > DeskReservedTo && ReservationEndTime < DeskReservedTo || 
        ReservationStartTime > DeskReservedFrom && ReservationStartTime < DeskReservedTo || 
        ReservationEndTime > DeskReservedFrom && ReservationEndTime < DeskReservedTo
    ).ReservedDeskID),
    Building = ReservationBuilding, Active = 1
)
0

So this is what I have done, I created a collection that stores all the reservations for the date and time selected. Since Filter is delegatable it will capture all the reservations.

ClearCollect(
    AvailableDesks, 
        Filter(DeskReservations,
        ReservationStartTime <= DeskReservedFrom && ReservationEndTime >= DeskReservedTo || 
        ReservationEndTime >= DeskReservedTo && ReservationEndTime <= DeskReservedTo || 
        ReservationStartTime >= DeskReservedFrom && ReservationStartTime <= DeskReservedTo || 
        ReservationEndTime >= DeskReservedFrom && ReservationEndTime <= DeskReservedTo, 
        ReservationBuilding = ReservedDeskBuilding, ReservationCancelled.Value = "No"
    )
)

I then use this collection to check to see which desks are not in the collection and thus free for reservation.

Filter(
    Desks,
       Not (
            DeskID in AvailableDesks.ReservedDeskID
            ), ReservationBuilding = Building.Value, Active.Value = "Yes"
    )

I do still get a delegation warning but I believe that this is from the Desks lists but as there will never be more than 2000 desks that should be fine, I have added a warning to the Add New Desk that alerts admin if 2000 desks are used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.