Issue with filtering because of full evaluation of AND operator

Hi,
I’m facing an issue due to the evaluation of both parts of an AND operator.
But maybe there is a solution I can’t find…

In my application, I need to hide a Table1 content if a user is not in a Table2.
If the user is in this Table2, then I need to filter Table1 with a column “content” of Table2.
(Maybe one day we will have a real user rights management in Coda that ends these inefficient workarounds…)

I do this with :

  • a named formula CurrentFilter : Table2.filter(user=user())
  • a filter in Table1 : user().in(Table2.User) and (table1.contains(CurrentFilter.content))

If user is in Table2, everything is ok but if he isn’t then there is an error in the filter because CurrentFilter is “empty” and so Content column does not exists.
I didn’t find any solution to solve the error : testing CurrentFilter.IsBlank() does not work neither user().in(Table2.User) because Coda evaluates the both parts of the AND.
Why does CODA do that ??
In every coding languages I know, the B part of an “A AND B” is never evaluated if A is False, because it allows that kind of things and it increases speed of execution !!

Thanks for your help

Hey @Stephane can you provide an example doc shared here?

Hi @Johg_Ananda,
Thank you for trying to help me.

I made a very simplified one you can find here :

This is a common one, so I just spun up a quick screencast about this:

3 Likes

Hi @Paul_Danyliuk ,

You’re my hero !!!

Thank you so much for the time you took to explain these 3 solutions.

I like your helper table solution a lot, because I used to create named formula : easy to use, helps a lot to debug.

You’re going to help me to solve others “untyped” similar problems, I learned a lot today.

(forgetting the .first() at the end of the filter() command is not a rookie error, it’s a “stupid guy with no memory” mistake, I do this one all the time…)

1 Like