Help with time booking logic

Hi guys! I need help with a show_if expression.

I have an app where users can fill in a booking form, among the form fields there is one for selecting a date and one for selecting a time. When the user submits the form selecting a date and time, if he tries to fill in again and selects a date that is within 7 days of his previous booking, he does not need to fill in the time field (I use show_if).

So, assuming I have reserved todayโ€™s date (10/22/2021), and then try to reserve any date between 10/22 and 10/29, I donโ€™t need to fill in the time field (in fact, the field shouldnโ€™t appear ).

I have a table where I record all reservations that contain time, I put the following logic in the show_if of the time field:
ISBLANK(FILTER(โ€œbookings_with_timeโ€, AND([Date]>=DATE([_THISROW].[date_to_book])-7,[Date]<=DATE([_THISROW].[date_to_book), [Email]=USEREMAIL() )))

This expression works sometimes. The idea is to filter the โ€œbooked dates with timeโ€ table, trying to bring up any row that: is from the userโ€™s email and the reservation date is within 7 days of the one he is selecting on the form. With the ISBLANK function I check if the filter has returned any value, if it has, the field is visible.

Has anyone tried something like this or have any tips?

0 7 214
7 REPLIES 7

Steve
Platinum 4
Platinum 4

Your expressions looks reasonable (though itโ€™s missing a ], which I assume is a typo in the transcription). I would be helpful to know more about the bookings_with_time table or slice, and about the date_to_book column.

Hey Steve, thanks for your answer. Yes, it is just a typo.

The bookings_with_time is just another table that contains the same columns as the main table (which the form populates). But it only contains the booking records that had to select the time. Itโ€™s not a slice, itโ€™s just another table that an action populates if the user selects the time. I didnโ€™t use a slice because in the future I intend to create unique columns for this table. The action works perfectly, so the reason the expression doesnโ€™t work is not due to lack of record in this table.

About the field you mentioned, itโ€™s just the date field that the user selects in the form, it has a different name from the field in the bookings_with_time table just to make the creation of expressions easier, but both contain the same data.

Steve
Platinum 4
Platinum 4

Can you share any observations youโ€™ve made about this behavior?

It work just for some users, I still donโ€™t know why.

Donโ€™t make any sense. I hope there is another logic I can use instead.

Iโ€™m afraid Iโ€™m at a loss, myself. Iโ€™m going to have to refer you to Support so someone thee can take a deeper look.

https://www.appsheet.com/Support/Contact

Thanks Steve. I found out what happened: we put a security filter on the bookings_with_time table, but as some users didnโ€™t pass the security filter, the expression didnโ€™t return anything and always asked for the time selection.

We created the security filter because this table has a view with a show_if expression and we didnโ€™t want some users seeing the data using a direct url to the view. There is any way to maintain the security filter, but that the expressions could do a bypass?

Not possible.

Top Labels in this Space