5 Replies Latest reply on Sep 6, 2011 10:43 AM by LaRetta_1

    Checkbox Script



      Checkbox Script


      I have a checkbox that needs to return "1" for checked & "0" for unchecked (using a single box, NOT two).  I tried writing a simple script using OnObjectModify trigger.  Here's what I did (not working):
          If [Order::Checkbox != 1]
              Set Field [Order::Checkbox[0]]
          End If

      Any help would be greatly appreciated!

        • 1. Re: Checkbox Script
           Add a 'show custom dialog' step temporarily to the top of the script, make it print the value of Order::checkbox so you can see what the value is, checked and unchecked, from there you can modify your script to behave as expected. This is a good way to debug scripts in general. If you're expecting your set field statement to set the field to zero, have another look at the definition of set field, the zero is supposed to be the value being set, not the repetition number, i.e Set Field[Order::checckbox; 0]
          • 2. Re: Checkbox Script

            Use a single step script:

            Set Field [ Order::Checkbox ; not Order::Checkbox ]

            BTW: you need neither a scrpt nor a trigger, just place this calculation into the auto-enter option for the check field:

            Self + 0

            • 3. Re: Checkbox Script


              Thanks for the tip.  With "Self + 0," I got a result of "null" (empty set... not what I wanted).  So, I adjusted the calculation in the auto-enter option for the check field to:  Self - 0

              However, I'm using a SQL DB & it seem to enter the "1" as a text, not a number.  I thought this would work for me (if it wasn't SQL, it would), so I checked it as "Best Answer" but now see it doesn't quite work


              • 4. Re: Checkbox Script

                This ?

                Right ( 0 & Self ; 1 ) 

                • 5. Re: Checkbox Script

                  BTW, I posted an alternate method but I see that raybaudi's suggestion works ONLY if you uncheck in calc dialog, 'do not evaluate if all referenced fields are empty.  So I deleted my suggestion.  Either calc will work; also be sure to disable 'do not replace existing data' as I've indicated.

                  And as I said originally, the records should pre-enter 0 as auto-enter DATA.