Case List : Multiple date on filter expression

(B.Gueye) #1

Hi All
i have many date like date_suivi_J1, date_suivi_J2, date_suivi_j3 until date_suivi_j20 and i want in a case list to filter date_suivi_J… will occur today.
So my question is: Is that possible to write on filter expression date_suivi* = today()_ ??

(Jessica Long) #2

Hi Babacar,

Great question. There’s not really a good way to use regular expressions on variable names, or to quickly scan many similarly-named variables. I agree that this can sometimes feel like a limitation while app-building.

There are two ways to handle your use case. The first would be to construct a simple OR expression:
(date_suivi_J1 = today() or date_suivi_J2 = today() or date_suivi_J3 = today() or …)

The second way would be to concatenate all of your days together into a single date expression:
all_dates = concat(date_suivi_J1, " ", date_suivi_J2, " ", date_suivi_J3, " ", …)

Then the boolean expression would be:
selected(all_dates, today())

The above boolean expression checks to see if the today() value exists in the space-separated all_dates list. Using space-separated lists can be a powerful way of automating value-checking in CommCare.

(B.Gueye) #3

Hi Jessica
i think the second is the best to do .
Thanks for the answer