11 Replies Latest reply on Apr 20, 2017 2:32 PM by philmodjunk

    Script CHECK, UNCHECKED Check Box and Vice Versa?

    ChristofferRexen_1

      Hello everyone,

       

      I am having a difficult time trying to figure and overcome this, relative simple, problem.

      - And yes, I have already been going through the Forum, but couldn't find any exact answer to my question

      [How to make a script CHECK an UNCHECKED check box?]

       

       

      I have a Checkbox consisting of 8 values, each value based of ID's from a foreign table.

      - See attached image.

       

      Now, this Checkbox is naturally empty at first, but should end up consisting of 2 values.

      - Only 1 Value from 1 of 4 of the Check Box values below "Industri"

      - Only 1 Value from 1 of 4 of the Check Box values below "Sundhedsforsikring"

       

      Say the Check Box consists of the 2 values; "Betjeningstilskud" and "Netto", but someday "Betjeningstilskud" changes to "Fast Honorar", although "Netto" remains.

      The client then just pressed the newly value "Fast Honorar", which in the perfect world, depending on which type of branch - "Industri" or "Sundhedsforsikring", and the value "Betjeningstilskud", "Fast Honorar", "Procent af præmie" etc.,

      UNCHECKS, "Industri", "Betjeningstilskud", sets "Industri, "Fast Honorar" and in the same time keeps/CHECKS, "Sundhedsforsikring", "Netto"

       

      Likewise, if the case were to be changes on the Sundhedsforsikring.

       

      Point is, only 1 value of each branch must be Checked at a time.

       

      1. Retain current values in a $Variable

      2. Uncheck the current checked value, depending on Branch

      3. Check the new value, depending on Branch

      4. Set the current value again, from other Branch

       

      Is this even possible, and if so... How do I do it with a script?

      I suppose it requires some hefty fiddling.

      - I have already tried a little, but find it difficult.

       

      Could anyone point me in the right direction.

       

      Regards

      CR

        • 1. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
          philmodjunk

          Some general observations:

          $currentvalues will not hold a value once the script ends.

          $$currentvalues, on the other hand, will retain a value

           

          A field formatted with multpile checkboxes stores selected values separated by returns in the order selected.

           

          This expresion can detect test if a specific value in the check box field is selected:

          Not IsEmpty ( FilterValues ( CheckBoxField ; Value ) )

           

          This expression can clear a check box while leaving other selections unchanged:

          Let ( [ TheList = pilcrow & table::checkboxfield & pilcrow ;

                     Newlist = substitute ( TheList ; pilcrow & ValueToRemove & Pilcrow ; Pilcrow ) ] ;

                      Middle ( NewList ; 2 ; Length ( NewList ) - 2 )

                  ) //let

          in the above expression use the pilcrow operator where I put the word "pilcrow".

           

          This script step will select a check box:

          set field [ table::checkBoxField ; list ( table::CheckBoxField ; ValueToSelect ) ]

          1 of 1 people found this helpful
          • 2. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
            ChristofferRexen_1

            Thank you so much for taking the time to help me out Phil, appreciate it!

             

            I am on the right path, although I did not quite get the following expressions, and still lack a bit help.

            This expresion can detect test if a specific value in the check box field is selected:

            Not IsEmpty ( FilterValues ( CheckBoxField ; Value ) )


            This script step will select a check box:

            set field [ table::checkBoxField ; list ( table::CheckBoxField ; ValueToSelect ) ]

            I want the script to validate, if one of the values has already been checked.

             

            Say... Values from 333 to 357, only 1 of the values between this span can be checked at a time.

             

            And... Values from 360 to 363, only 1 of the values between this span can be check at a time.

             

            Is this doable in extension of the current script?

             

            Best regards

            CR

            • 3. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
              philmodjunk

              You haven't explained those numbers. Did you set up a "use values from field" value list where these are the ID values and the visible values associated with your check boxes are the "name"  values from the same record as the ID?

               

              Say... Values from 333 to 357, only 1 of the values between this span can be checked at a time.

               

              And... Values from 360 to 363, only 1 of the values between this span can be check at a time.

              This sounds like data that should be managed as two radio button fields instead of check box fields. A check box format implies to the user that more than one value may be selected. Radio button formatting implies that only one value may be selected.

              • 4. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                ChristofferRexen_1

                Sorry I didn't mention this at first.

                Yes, the value list set up using "Use values from field" and visible values are associated with the "name".

                 

                You are quite right regarding how it should be handled.

                Although the customer I am working for, has customer cases where some of the values are combined, which is why I chose towards the Check Box.

                 

                Although the Radio Button sounds way safer -- how is set up?

                I am using the same field for storing both values with a "List ()" function.

                 

                If I were to use the Radio Button, this would require 2 fields, since I would like the same field to store two different values?

                - 1 for the "Industri" value

                - 1 for the "Sundhedsforsikring" value

                Or how does this work, correct me if I am wrong?

                 

                If not possible, then how do I set it up with a Check Box?

                • 5. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                  philmodjunk

                  You set up radio buttons just as you do check boxes. It's just a different option in the Inspector.

                   

                  I would not use two fields if your are storing different values. Please note that:

                  Values from 333 to 357, And... Values from 360 to 363,

                  tells me very little about the function of these fields and why they are set up that way. Sometimes, neither a single check box nor a single radio button field with multiple options is even the best option for data entry. Sometimes it is better that selecting a value from one of these lists creates a record in a related table and clearing that selection deletes one. This can look and function like a single field of radio buttons or check boxes, but you gain options in user interface design and reporting not readily possible with a single field with a list of return separated values.

                   

                  Also note that a script used to set a radio button formatted field to a specific value is just a simple set field step:

                   

                  Set Field [ YourTable::RadioButtonField ; Value ]

                   

                  And while a radio button format implies a single value selection only, Filemaker allows users to break this rule by holding down shift or control while clicking radio buttons. Thus, an auto-enter calculation that  blocks this action is often useful:

                   

                  GetValue ( Self ; ValueCount ( self ) ) // clear the "do not replace..." check box.

                  • 6. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                    DavidJondreau

                    Why not use two fields?

                     

                    if you must have the two values in the same field, combine them into another field by calculation.

                    • 7. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                      ChristofferRexen_1

                      David Jondreau wrote:

                       

                      Why not use two fields?

                       

                      if you must have the two values in the same field, combine them into another field by calculation.

                      Cause it would require a total of 3 fields in the end.

                      • 8. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                        ChristofferRexen_1

                        philmodjunk wrote:

                         

                        You set up radio buttons just as you do check boxes. It's just a different option in the Inspector.

                         

                        I would not use two fields if your are storing different values. Please note that:

                        Values from 333 to 357, And... Values from 360 to 363,

                        tells me very little about the function of these fields and why they are set up that way. Sometimes, neither a single check box nor a single radio button field with multiple options is even the best option for data entry. Sometimes it is better that selecting a value from one of these lists creates a record in a related table and clearing that selection deletes one. This can look and function like a single field of radio buttons or check boxes, but you gain options in user interface design and reporting not readily possible with a single field with a list of return separated values.

                         

                        I have created a table called "Billing Model".

                        The Value List is based on the values of this table.

                        Each "Billing Model" consists of a certain number of Invoicelines, which is used to Invoice the customer.

                        The person responsible for the customer, is forced to consider which "Billing Model" to be used for the customer, before being able to Invoice the customer. 

                        There are to branches, "Industri" and "Sundhedsforsikring", sometimes only "Industri" is active, sometimes only "Sundhedsforsikring", and sometimes both, which as described, is used to Invoice the customer in different types of situations.

                        Although, since only 1 value can be active at a time under each branch, I chose the Check Box.

                        Although the trick with the Radio Button is also a pretty neat thing -- although I fear the clients won't know how to use it.

                         

                        Hope it makes sense?

                         

                        Although how I read your post is, that you are saying it could be easier to create reports and alike, with a created record, based on what the person, responsible for the customer, set as value in the first place?

                         

                        CR

                        • 9. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                          DavidJondreau

                          It's unclear if you do need a third field, but even so, that's not a reason not to split the field.

                           

                          A database should have as many fields as it needs, and not more.

                           

                          You could this this and be done, moving on in less than 5 minutes.

                          • 10. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                            Malcolm

                            If you are splitting the field data entry options into two sections that suggests the data should also be in two sections, doesn't it?

                             

                            Malcolm

                            • 11. Re: Script CHECK, UNCHECKED Check Box and Vice Versa?
                              philmodjunk

                              Please note that any advice that you get is currently based on a very, very limited view of what you are trying to do and why.