I guess the first thing to understand about the Glide if-then-else column is that it is exactly what it says it is: if-then-else
It’s not if-and-then-else, it’s not if-or-then-else, and it’s not if-and-or-then-else.
If you’ve ever done any programming, you can think of it being a bit like a switch statement. That is, you have a series of conditions, and as soon of one of those conditions matches it will execute the associated block and return. And if all else fails, you have an optional default condition to fall through to.
It might seem very limiting at first, but with a little bit of creative thinking you can handle some quite complex conditional logic with a single if-then-else column.
In general, the trick is to work your way backwards. That is, instead of twisting your brain trying to come up something that returns true straight off the bat, just start by eliminating your negative conditions one by one. And then anything that makes it past all that can be considered “true”.
A simple example is creating a validation check for required values in a custom form. Imagine that you have a form where a user enters name, email, title, avatar and you don’t want to allow them to submit the form unless they’ve provided all values. You’d be tempted to try and do something like “if name is not empty, and email is not empty, and title is not empty, and avatar is not empty, then true”
But of course you can’t do that. But by working backwards and using a process of elimination, it becomes easy:
- If name is empty, then null
- if email is empty, then null
- If title is empty, then null
- If avatar is empty, then null
- Else true
It can take a bit to get used to it, but once you have your head around it, it’s not too bad.
If you have specific examples that you’re struggling with, feel free to post them and we’ll do our best to help you out.