Does anyone know how to perform data validation on a Enum List so that the user is required to pick ONE certain item in the list, but could also select that required option along with others.
For example, If I had the following list but wanted to require โCatโ was selected.
Accepted: Cat
Accepted: Cat, Dog, Bird
Not Accepted: Dog, Bird
Any help with this would be appreciated. Thanks!
Solved! Go to Solution.
Interesting. I did not expect this particular issue in this situation. A better solution would be:
AND( TRUE, IN( "Cat" , [_THIS] ) )
If you use CONTAINS, that would also allow someone so select, say โBobcatโ, without selecting โCatโ as well.
IN( "Cat" , [_THIS] )
So simple yet it was making me bang my head against the wall. Thank you so much Marc!
You could use this awesome post by Matt showing how to make custom messages when the validation rule says it canโt be save
I know itโs kinda advance but itโs a good resourse of improvement/knowledge
At first glance this seemed like the obvious answer. After trying to implement it makes it so that field does not appear at all in my form. Any other ideas?
Interesting. I did not expect this particular issue in this situation. A better solution would be:
AND( TRUE, IN( "Cat" , [_THIS] ) )
If you use CONTAINS, that would also allow someone so select, say โBobcatโ, without selecting โCatโ as well.
I definitely overlooked the fact that CONTAINS could potentially create some problems. I tried your most recent post and it worked well and has been marked as the solution.
Do you know why adding the AND/TRUE will allow it to work? It seems redundant, as the logic creates the same end result.
I was kind of hoping you werenโt going to ask, lol.
Its intention is to avoid a certain automatic behavior within Appsheet. But that is not for this exact situation. So really Iโm not sure exactly why its needed here. I think it may just be some small edge-case glitch.
Consider the situation where you have a single-value column (Text,Enum,Number,etc), and you want to validate the input against a List somewhere, but you do not want to show a dropdown. Youโd initially think to use a simple IN( [_THIS] , list-to-check )
. However, Appsheet likes to automatically create dropdown lists when it sees a simple IN() expression in the valid_if, so youโd get a dropdown. The common approach there is to basically create a logically-equivalent expression, but so itโs not just a simple IN(). Both OR( FALSE , IN() )
and AND( TRUE , IN() )
accomplish the same thing.
So, even though your situation is quite different, since itโs still a simple IN() in the valid_if, I figured the same solution would work.
Haha! Well thank you for taking the time to explain it to me! That makes perfect sense. Hopefully in the future I will now be able to figure it out on my own so I can keep the โunwanted questionsโ to myself! lol
Thanks again!
I tried a slightly different version of your solution using โContainsโ instead of โInโ and it works perfectly now.
Contains([_THIS],โCatโ)
Thanks again!
User | Count |
---|---|
40 | |
36 | |
32 | |
23 | |
16 |