Hey guys!
So it may sound silly!
Many of us might have faced this issue before!
We have an element that is to be visible by Role A or Role B and the signed in user should satisfy one more condition.
So the problem is:
Element Visibility is ((role = “Role A” or role = “Role B”) and verified = isChecked)
Any suggestions on how to achieve this!
P.S. I already have an answer, but this is somewhat of a challenge to the community!
I’ll post the answer in a day’s time and let the challenge be here till then!
My fallback would be to us a single IF column to return a true/false value for simplicity sake, and then use that for the visibility condition, since it is slightly more flexible than building a visibility condition.
But, since you threw out the challenge to not use any additional computed columns, I have a couple of ideas:
The first idea would require knowing all other potential roles (hoping that they remain fairly static and you don’t add new roles in the future).
So let’s say you have Roles A,B,C,D. I would structure the visibility conditions with AND, so all conditions must be true. This is how I would do it purely with a visibility condition and no computed columns.
IF Role != C
AND
IF Role != D
AND
IF verified = isChecked
The only problem is that it’s not scalable if new roles are added, so all visibility conditions would have to be updated each time a role is added that should not make the component visible.
The second idea, which is a lot simpler, is to structure your visibility condition like this:
IF Role is included in ‘Role A,Role B’
AND
IF verified = isChecked
I’m leary about using ‘is included in’ or ‘includes’ only because of the potential for it to pick up unintended matches, but if you have good control over the potential values, then there shouldn’t be a problem.
More interesting is that you can use any character/symbol as “separator” and the logic still works… WTF!
I mean, theses cases/syntaxes can be used:
IF Role is included in ‘Role A/Role B,Role C’
AND
IF verified = isChecked
… or this one
IF Role is included in ‘Role A Role B; Role C’
AND
IF verified = isChecked
but there will be problems if our logic finds a match on some string (the Jeff´s concern).
E.g.:
If you have these Roles names: Admin, Admin-EN, Admin-SP and Full Admin
the logic bellow will fail because the Admin word is contained in these 4 cases:
IF Role Type is included in ‘Admin’
AND
IF verified = isChecked
but anyway, it’s good tip if we do all this very carefully and don’t use words with similar letters.
Thanks!
As fas as I’m concerned, the if-then-else column solution is the best, and the one I will always use once I have more than a single condition. It’s the easiest to maintain - especially if the condition needs to be applied to multiple components - and it doesn’t violate my personal mantra of keeping as much logic as possible in the data editor.
I agree with your comments regarding the is included in option. I consider that fragile and easily broken, and I would avoid it.