11 Replies Latest reply on Feb 9, 2015 9:22 AM by ishulman

    Checkbox conditionals



      Checkbox conditionals



      I don’t think is so hard to solve, I’m just not that good at FileMaker.

      What I want to do is print multiple layouts at the same time.
      Using a script that looks like this works just fine:

      Go to Layout [Layout 1]
      Print [Perform without dialog]
      Go to Layout [Layout 2]
      Print [Perform without dialog]

      And so on…

      BUT…. I would like to be able to choose WHICH layouts to be printed.
      And I would like to do it with checkboxes.

      Let’s say I have 3 different layouts which I would like to be able to print.
      And I want to have 3 checkboxes that represents a specific layout (to help me choose).

      So, if I choose checkbox 1 and 3, layout 1 and 3 should be printed but not number 2 (see screenshot).

      Is that possible to script?

      I was thinking I should us “If” values, like If check box 1 = yes, print. If checkbox 2 = no, the skip to next checkbox check, (you get the idea).
      But I could not make it work.


        • 1. Re: Checkbox conditionals

          Set a "script trigger" on your checkboxes and set it to "on modify"

          Then your script can have a script step to set a variable for each check box

          Then your script can then use a series of IF statements. IF variable_SOandSO = Yes, then go to layout variable_SOandSO, print without dialog, then move to next IF statement.

          If you need an example, let me know.



          • 2. Re: Checkbox conditionals

            Hi and thank you for a very fast reply!

            I would really appreciate an example! laugh

            • 3. Re: Checkbox conditionals


              I tried to follow your instructions.
              But you lost me…smiley

              Can I have multiple checkboxes in the same field, or do I need to separate them so there will be one field for each checkbox?

              If I use multiple checkboxes in one field, how do I collect that information in a script?
              I use “script trigger” with “on modify” and points it to my script (which is empty right now).
              Then what? smiley

              So yes, I really need that example of yours blush

              • 4. Re: Checkbox conditionals

                With multiple values in a check box field, use the following calculation to detect whether or not a specific check box is selected:

                Not IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Value" ) )

                This expression returns True if the check box for "Value" was clicked.

                • 5. Re: Checkbox conditionals

                  Thank you PhilModJunk for your reply!

                  I used your example, and it helped me a bit on the way.
                  What happens now is that in the exact same moment I click on a checkbox the script triggers and the layout prints. And that is not quite what I want.
                  What I need is to be able to select all the layouts to print and THEN run the script.

                  The result I want is:
                  I mark checkbox 1 and 2 but not 3. Click the print button, the script runs and layout 1 & 2 prints.

                  So, I somehow need to make the script store information about which checkboxes are checked and then print.
                  Do I make sense at all? smiley

                  • 6. Re: Checkbox conditionals

                    Hi all!
                    I found the problem. It was my script trigger (of course) that made the script run when I checked a checkbox. So removing the script trigger made everything work exactly as I want it to!
                    Thank you all!


                    • 7. Re: Checkbox conditionals

                      Magnus, Your question reflects exactly what I'm looking to do, but with 5 checkboxes in a single field. I'm confused about the specific steps needed to set that up. Can you assist?

                      So far, I have created a single, checkbox field called PRINT FORMS that draws its contents from a value list of the same name, set to "Use Custom Values" of Layout 1, Layout 2, etc.). This gives me a single field with the multiple checkbox items I need. My questions are:

                      A) Should I denote the PRINT FORMS field as a Text field or as a Calculation?

                      B) Where does Phil's calculation from Dec 10/14 go?  

                      C) When I use Phil's calculation, do I need to use AND or OR, or some other modifiers between the various values

                      eg, Not IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Layout1" "Layout2" "Layout3" ) ) 

                      or do I need multiple versions of that statement

                      eg Not IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Layout1" ) ), Not IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Layout2") ), Not IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Layout3" ) )?

                      Thanks & I hope I can follow up with any additional questions I have about this.


                      • 8. Re: Checkbox conditionals

                        A) you can't set up a calculation field with a check box format and then be able to modify it by clicking check boxes. This check box field should be a field of type text.
                        B) you would set up a Script with a series of IF blocks, each of which specifically tests for a different value that might be selected by clicking a check box:

                        If [ IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Layout1" ) ]
                           Go to Layout [ "Layout 1" (Layout 1)]
                           Additional code to print goes here (steps here can very with design of your database)
                           GO to layout [ original layout]
                        End If
                        If [ IsEmpty ( FilterValues ( YourTable::YourCheckBoxField ; "Layout 2" ) ]
                            and so forth...

                        C ) see answer for B

                        • 9. Re: Checkbox conditionals

                          Hi ishulman,


                          PhilModJunk is right.
                          Your filed containing checkboxes should be a text field.

                          All I did was this:

                          a) Create a text field containing checkboxes and pick values from a value list (Layout1, Layout2…). Just as you describe.

                          b) Create a script that will look like this:
                          If [not IsEmpty ( FilterValues (YourTable::YourCheckBoXField ; “Layout1”) )]
                                                       Go to Layout [“Layout1” (FileMakerFileName)]
                                                       Print []
                          End If

                          That’s pretty much what PhilModJunk said, but I have a “not” in the beginning of the If-command.

                          What the script does is to check if a checkbox is checked or not.
                          If it is, it will go to that layout and print, and then next selected layout and then print and so on.

                          I added custom dialog box in the beginning of the script asking the user if he/she really want to print. If they select no, the script will be aborted.

                          • 10. Re: Checkbox conditionals

                            My mistake there, There needs to be  Not IsEmpty inside each IF step. left out the Not by mistake.

                            I will also note that if your value list contains exactly the same text as what you used to name each layout, there's a simpler looping script that might be used with the GetValue function inside a Goto Layout, Calculation by name step but only if you can do the exact same script steps for printing every layout, which is not always possible as setting up a particular layout for printing may require more steps than just a Print step.

                            • 11. Re: Checkbox conditionals

                              Thanks to both of you. I really appreciated the very specific replies. The concept is actually pretty simple, but I wouldn't have come up with the Not IsEmpty FilterValues syntax myself.