6 Replies Latest reply on Jan 31, 2017 10:50 PM by JackRodges

    Simulating Radio Button Control with 2 boolean fields

    ericjlindholm

      I would like to simulate radio button functionality with 2 boolean fields. 

      by that I mean, if one is set true, set the other false.

      Right now I have a radio button text field with a value list containing 2 values.  and the 2 boolean fields evaluate if one or the other value is set in the text field

       

      This is a bit brittle, relying on the text field.  I would prefer an auto enter calc on the fields isCustomer and isVendor but my numbers attempts have failed.  I know I can script something but I prefer to bake it into the data model where I can. 

       

      example:

       

      Currently -

      Company::isCustOrVendorv is text field with radio button control with the value list Customer Vendor.

      Company::isCustomer is a number field that auto evaluates  if ( company::isCustomerVendor = "Company" ; 1 ;"")

      Company::isVendor is a number field that auto evaluates  if ( company::isCustomerVendor = "Vendor" ; 1 ;"")

       

      1 of a few not functioning attempts -

       

      Company::isCustomer Auto Enter Calc  if( isVendor; "" ; 1)

      Company::isVendor Auto Enter Calc  if( isCustomer; "" ; 1)

       

      Thoughts?

        • 1. Re: Simulating Radio Button Control with 2 boolean fields
          IT_User

          Can still have the radio button instead of the boolean field, but have the values be numbers instead of whatever value, if that makes it easier to calculate. (On the layout, the number values can be hidden, and a text field [for the label] can be shown beside it.)

           

          However, in doing this with two boolean fields, what is the goal of this?

          • 2. Re: Simulating Radio Button Control with 2 boolean fields
            ericjlindholm

            In this example, Lets say I don't want use the logic a company is a Customer if they are not a Vendor.  I could do that with a single boolean field. 

             

            Lets say a company could be might not be either but they could not be both.  It also just makes my coding flow a little easier in my mind to just type if( customer::isVendor)  and if( customer::isCustomer) to call for a true value in those fields. 

            • 3. Re: Simulating Radio Button Control with 2 boolean fields
              keywords

              Here is an alternate approach you might like to consider:

              Screen Shot 2017-02-01 at 8.42.09 AM.png

              The screenshot shows two methods. The Single-value Value List contains simply 1. At top you see the field with the value visible, but below is how I display it—the field is set to only display the checkbox, not the value. I can then set it beside a value of my own choosing (Yes, True, Happy, Smart, whatever).

              The Multiple-value Value List contains, in this example two values, 1 and 2, but can contain more if you wish. Again, the second version shows how to display it as a vertical set of checkboxes alongside whatever characteristic you wish to assign to each value.

              Note that this method uses checkboxes, not radio buttons, but it could also be used for the latter. The differences would be that: (1) a checkbox is easier to uncheck than a radio button (have to use shift + click to uncheck a radio button, and not all users know that); and (2) radio buttons behave as if they allow only a single value (but can shift + click to add instead of replace values), whereas checkboxes allow multiple values by their nature.

              • 4. Re: Simulating Radio Button Control with 2 boolean fields
                user19752

                Your problem would be if you set auto-enter on 2 (or more) fields referring each other, calculation become infinity loop then result empty.

                 

                Using

                 

                Let ( a = isVendor ;

                Case ( $$mod ; Let ( $$mod = "" ; "" ) ; Let ( $$mod = 1 ; Self ) )

                )

                 

                and for isVendor

                 

                Let ( a = isCustomer ;

                Case ( $$mod ; Let ( $$mod = "" ; "" ) ; Let ( $$mod = 1 ; Self ) )

                )

                 

                Then when you check one of two, another field will be cleared.

                 

                Bad thing is using $$variable, so you need taking care of conflicting. Similar thing can be done without variable if the fileds are edit box, but check box never be active.

                • 5. Re: Simulating Radio Button Control with 2 boolean fields
                  Markus Schneider

                  one field, number

                  inspector: Option boolean

                   

                  place that field 2 times in the layout

                   

                  Inspector lets You display non-zero values (boolean option) as a character by Your choice, choose one of the 'bullet' character

                  One of the fields has bullet for non-zero and blank for zero, the other one vice-versa

                   

                  the value of the field can be set by a one-liner (acts as a button): abs(YourField - 1)

                  -> click on that field to toggle...

                  (the scriptstep should be better a 2-liner, abs(...) and commit record)

                  • 6. Re: Simulating Radio Button Control with 2 boolean fields
                    JackRodges

                    Your ambition will automatically eliminate customers who might be vendors, vice versa. Checkboxes might be a better choice:

                     

                    __ Customer ___ Vendor  _Lead  __Friend  __Etc

                     

                    This would let you classify a person in multiple ways. Then create calc fields:

                    If patterncount(cbx; "Customer" ) > 0 ; 1 or true or ? ; "" or 0)

                    If patterncount(cbx; "Vendor" ) > 0 ; 1 or true or ? ; "" or 0)

                     

                    These ifs also work for conditional formatting...