I’m struggling to incorporate a boolean operator into my constraints for a repeating group.
For context, I have a database of health checks, which are for females, males, or both. I want to create a constraint of type Sex = Current User’s Sex OR “Both”, but I can’t utilise the OR operator. I don’t know why the OR operator doesn’t appear and I can’t figure out any workarounds.
I’ve attached a screenshot of the properties for further context. Any and all help is greatly appreciated!!
You can use the :merged with operator here
Do a search for Health checks (Sex = Current User’s Sex) merged with Do a search for Health checks (Sex = “Both”)
You can use the :advanced filter to put your filter conditions
Use :merged with so the searches will all be done backend and only return the desired results.
An advanced filter will return ALL matching constraints from the Search first, then run the advanced filter client side. So you not only spend more WU but advanced filters on large lists can and will literally slow down your app for your user because it’s doing all the processing in the browser.
Best approach in situations with 3 choices like this is to use the does not equal in constraint as I suggested. It’s just one search, gets same result.
The all round most straight forward way would be to just store it as a List of Sexes, Male and Female, and then you don’t have to handle opposites and the associated UI, can search for Health Checks with one sex, or both (by using two constraints on one search) very easily.
By making an option ‘Both’ it’s kind of over complicating it because Both = Male and Female - so just make it a list that can be Male, Female, or Male and Female.
I think if they’re willing to change the sexes to their opposites then they’d surely be willing to just change the field to a list which is the more standard option
I want to create a constraint of type Sex = Current User’s Sex OR “Both”, but I can’t utilise the OR operator. I don’t know why the OR operator doesn’t appear and I can’t figure out any workarounds.
An alternative to using :merged is to define a list of the Sex values you want to use for the constraint, then just use ‘Sex is in’ that list.
You can define that list in a variable somewhere (i.e. a custom state/RG/or RE property), OR you can define it directly in the search constraint.
So:
Sex is in Current User's Sex: converted to list: plus item: Both
Best approach in my opinion, add attribute to option set, related to the option set that is opposite. Then use constraint does not equal selected sex option opposite.
One search, no change to data structure or logic to save values, simplest dynamic expression for constraint value.