Jump to content

Checkbox sets and looping IF statements

Recommended Posts

I'm a dentist. I'm trying to generate written treatment plans for patients to have as a treatment estimate and for our records.

People have 32 teeth, therefore I have setup a field (ToothNumber), displayed as a checkbox set utilizing a value list = 1 through 32. When I click my CROWN script button, it opens a selection window wherein I choose the tooth number from said field (1-32), the material the crown is to be made of (porcelain, gold, zirconia, etc.), whether I want to use lab-processed temporary crowns, and so forth. 

If I have only one tooth number checked and run through my nested IF statements, which looks up the official description for the type of crown, the ADA code, the fee, the time required, etc., it all works fine. If I have more than one tooth number selected in the checkbox set, it only returns one line for the first tooth checked. 

The IF statement looks something like: If TOOTH NUMBER = 2 and CROWN MATERIAL = porcelain and LAB TEMP CROWN = "Yes" then it adds a line on the treatment items table which looks up appropriate description, ADA code and fee, so the patient has a copy and so do we. And we're both on the same page regarding what they want to accomplish. 

Am I using the wrong method for displaying and relating my selections? If so, what's the best way to accomplish this. Also, I want to avoid repeating the same sequence for each tooth number, i.e., I'd rather LOOP to advance through tooth 1 through 32. Any ideas? 

Share this post

Link to post
Share on other sites

OK, a checkbox set is a visual display of a list of checked items. So, if you checked tooth 3, 7, 10 it is stored as


So your looping script needs to run for each of these listed values. You use the GetValue function to grab each of them.


Set Variable [$list; Table::ToothList ]
Set Variable [$count; ValueCount ( $list)]
Set Variable $i //Counter for the loop iterations
  Set Variable [$whichTooth; GetValue [ $list, $i ]
   Perform Script [ Your script, passing the value of $whichTooth ]
  Set Variable [$i; $i + 1 ]
  Exit Loop If [ $i > $ count]

So it runs the script for each checked tooth...

Share this post

Link to post
Share on other sites

Thanks, Webko. I'll give it a try. 

My wife and I come to your country once or twice a year, mostly Melbourne but also Brisbane and Sydney. It's always a treat to be there, even in winter, getting us out of the oppressive Florida heat and humidity. 

Share this post

Link to post
Share on other sites

All right. I tried a number of iterations of your suggested script, but can't get the treatment line items which are tooth-number dependent to display on the treatment list. I'm attaching screen shots of both the Loop section with preceding Set Variable steps, and the window where the teeth and materials are selected. Here's how I interpreted it:

(I trust you'll let me know when the meter is running and I owe you a fee for helping me.)

Screen Shot 2016-11-24 at 10.16.56 PM.png

Screen Shot 2016-11-24 at 10.18.37 PM.png

Share this post

Link to post
Share on other sites

Off top of my head - $count should be a count of how many items are in the $list - so, as I wrote it, not all the possible values

$whichTooth will be set to the current value depending on the position in the list (determined by $i) - so no need for the If statement

Have a look at those first - I'm about to finish up for the week, so if you're still having issues Sunday your time, post a zipped copy of the file here for people to look at...

Share this post

Link to post
Share on other sites

Got it working now. Thanks so much for the insight. I will have lots more use for these script steps in future. 

Share this post

Link to post
Share on other sites

Also, don't forget to add a commit after the set of 'set field' steps. You don't need one for each just one after the group before you do something else.

Sent from my iPhone using Tapatalk

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Tondats
      Hello FM Gurus, good morning.
      Currently, I'm making a solution it's called "Enrollment and Grading System" of a certain school here in our place.
      I'm having a problem here with this Checkbox. (Image Below)
      As you can see in the image, I checked all the boxes on the checkbox list but unfortunately it will display only the letter "M". 
      I want the output should look like this "MTWThF".
      I really need your help guys. Does anyone here can help with this?
      Thanks and God bless!

    • By NewBoard
      I am attempting to use the following script in a Database:
      Set Variable [$supplierCount; Value: ValueCount ( List ( Suppliers::UUID ) )] Set Variable [$month; Value: MonthName ( Get ( CurrentDate ) )] Set Variable [$suppliers; Value: List ( Suppliers::UUID )] Loop Set Variable [$i; Value: $i+1] Exit Loop If [$i > $supplierCount] New Record/Request Set Field [Month::Month; $month] Set Field [Month::fk_Supplier; GetValue ($suppliers ; $i )] End Loop  
      When I run it, however, it creates zero New Records within my "Month" database.
      I'm not sure what the issue is. My only hunch is that the List function isn't properly creating a List of the "Suppliers::UUID" field, and is causing the ValueCount taken of it to return 0.
      Please let me know of any additional information I can provide, and thank you in advance for any assistance you can offer!
    • By DreadDamsel
      Hi, I have a bit of a dilemma that I've tried a number of solutions to sort out, to no avail.
      I have a portal that lists the participants in a class. In each row is a checkbox that can be used to indicate whether that participant has withdrawn from the class.
      I've used a summary field to count the number of checked boxes and have a field that subtracts that number from the total of records in the portal - easy peasy.
      Where it gets tricky is that, one of the fields relates to the number of children associated with a participant (a mum may have 3 kids in the class if it's one of the playgroups). Now I need to know how many kiddies there are in the class. I have a field that totals the number of children in total and that works fine, but...
      ... and here's my problem -
      where a parent has withdrawn (and the box is checked), I need to subtract the number of children associated with that parent from the total number of children).
      The checkbox is a value list with a single value, 1.
      All the solutions I've tried so far are fine unless it pertains to portal rows - and I can't figure it out for the life of me.
      Can anyone help me out?
    • By Quito
      I want to create a Dropdown List of numeric options to select a range of records.  For example, the Dropdown list would contain:
      Each option would select the next 5;10;20;50 or 100 records to the right.  A Checkbox would be populated (with an X) in the selected number of contiguous records; Then, a Find Selected Checkboxes would return the selected records.  The contiguous selection should be independent of whatever the current state of Found (Sorted/Unsorted) is.
      Any help will be gratefully acknowledged.
    • By crazybake
      I have a Value List "Quarter" with values:
      I planned to loop through these values and assign to a field using the various posts in the forum, but in testing the basic steps it's not working:
      Set Variable [$i; Value: 1]
      Set Variable [$quarters; Value: ValueListItems (Get (FileName); "Quarter")
      Set Variable [$count; ValueCount ($quarters)]
      New Record/Request
      Set Field [Program::ProgramQuarter; GetValue ($quarters; $i)]
      The field ProgramQuarter is not being set to any value....
  • Who Viewed the Topic

    6 members have viewed this topic:
    SupportGuys89  historychef  R2D2  Ponderosa  JC43  Lee Smith 
  • Create New...

Important Information

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