Jump to content

Constraining with multiple checkbox values


This topic is 2914 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm stuck. I have a checkbox'd text field (Phase__lxt_) with five values in it (I, II, II, IV, and ALT) to select from where I want users to be able to click one or more checkboxes to constrain found records having one or more of those values.


The problem is, I'm having trouble figuring out how to set up a script/calc for multiple value choices; single value choice is easy, but short of creating separate script iterations for each possible combination of checkbox seems incredibly clunky to me. 


I get that I'll need to parse the field in some way where I'll use FilterValues, PatternCount and such, but whatever the calc ends up being it'll have to ignore the order in which the checkboxes were checked.


As always, your help/guidance is greatly appreciated!

Link to comment
Share on other sites

Constraining to multiple values does not work - meaning you already have a found set and you want to use Constrain script step to reduce the found set to all the values in a checkbox.  Instead, find all these values and then Extend or Constrain by additional criteria. Use a global text to hold the user-selected values with a value list attached as a checkbox, called gPhase and then loop and create multiple find requests, similar to this pseudo-script:

# Make sure there is a value in the global text
If [ IsEmpty ( table::gPhase ) ]
Show Custom Dialog [ Message: "No value entered "; Buttons: “OK” ]
Halt Script
# count values in the global and loop them
Set Variable [ $valueCount ; ValueCount ( table::gPhase ) ]
Enter Find Mode [  ]
Exit Loop If [ Let ( $count = $count + 1 ; $count > $valueCount ]
# one new record/request for each value
New Record/Request
Set Field [ table::Phase_lxt_ ; GetValue ( gPhase ; $count ) ]
End Loop
End If
Set Error Capture [ On ]
Perform Find [  ]
Link to comment
Share on other sites

Each new find request create an OR condition meaning records with ANY of the checked values will be found.  If you want a find which returns records only if ALL of the criteria is included, just one find will work based upon the global checkbox; which creates an AND find.


Edited ... 

Edited by LaRetta
Link to comment
Share on other sites

Hi Lee,


When searching the same field for multiple values, a Constrain would fail.  If you constrain down to the first value, then attempt to constrain down to the second value, it would never return a result because it already has constrained the record set to only the first value.


So what you reference IS correct - when searching different fields but that's why I said a constrain would not work on checkbox and instead it works best to perform multiple find requests, creating an OR condition, as ... search the checkbox for value 1 OR value 2 OR value 3 (regardless of their order in the checkbox)  ... and if you wish to constrain to certain date range (for example) THEN constrain the existing found records to the date range.  


I appreciate you speaking up because I see that I DID mis-speak in mentioning the AND find on checkbox.  It would fail unless the checkbox was in same order.  Thanks for speaking up and I'll delete my AND reference above. :-)

Link to comment
Share on other sites

This topic is 2914 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.