10 Replies Latest reply on Dec 11, 2013 12:24 PM by raphthepenguin

    automatically check checkbox

    raphthepenguin

      Hey,

       

      I have a checkbox for a paymentplan set and to each value I have a date.

      My goal is to automatically check the checkbox when the corresponding Date is filled in.

       

      I wrote a simple script:

       

      Set Field [checkbox; Get (Scriptparameter)]

       

      then I set the scripttrigger for the field on onobject modify and the Scriptparameter to the Corresponding checkbox value...

       

      so far so good.

       

      This script actually works... Only one problem.

      Previously checked boxes get uncecked.

       

      How do I have to change my script so that it just adds the checking to everything previously already checked?

       

      Thanks

        • 1. Re: automatically check checkbox
          erolst

          raphthepenguin wrote:

           

          Set Field [checkbox; Get (Scriptparameter)]

          Set Field [ table::checkbox ; List ( table::checkbox ; Get ( ScriptParameter ) ) ]

           

          At a guess, you're using fields for something that could better done with related records …

          • 2. Re: automatically check checkbox
            ryantittle

            Perhaps try

             

            If checkbox does not equal Get (Scriptparameter)

                 Set Field [checkbox; Get (Scriptparameter)]

            End If

             

            or maybe If  isempty ( checkbox )

            • 3. Re: automatically check checkbox
              Stephen Huston

              raphthepenguin wrote:

               

              Set Field [checkbox; Get (Scriptparameter)]...

              This script actually works... Only one problem.

              Previously checked boxes get uncecked.

              Try something like:

               

              If [ isEmpty(checkbox) ]

                   Set Field [checkbox; Get (Scriptparameter)]

              Else

                   Set Field [checkbox; Checkbox & "(paragraph/returnSymbol within the quote marks)" &Get (Scriptparameter)]

              End If

               

              That will preserve your existing value while adding the checkbox value to the field contents. Checkboxes allow multiple values, which are generally coded as return-separated wen looked at as plain text (non-checkbox formatted) fields.

              • 4. Re: automatically check checkbox
                erolst

                Stephen Huston wrote:

                 

                If [ isEmpty(checkbox) ]

                     Set Field [checkbox; Get (Scriptparameter)]

                Else

                     Set Field [checkbox; Checkbox & "(paragraph/returnSymbol within the quote marks)" &Get (Scriptparameter)]

                End If

                 

                Stephen –

                 

                Why not simply use List (), which does exactly that “for free”?

                • 5. Re: automatically check checkbox
                  ryantittle

                  Glad you posted. Just realized I had accidentally typed "not isempty."

                   

                  I think we are both missing something though. I think the script parameter would also have to be checked to have a value. An empty parameter is the only way that I can reproduce the checkbox being cleared when I try.

                   

                  As a matter of fact, that might be all that is needed depending on what/how many possible values could be needed in the checkbox. Setting the field to the same value over and over again does no harm, really.

                  • 6. Re: automatically check checkbox
                    raphthepenguin

                    Thanks very much Stephen! This did the trick for me!

                    • 7. Re: automatically check checkbox
                      erolst

                      raphthepenguin wrote:

                       

                      Thanks very much Stephen! This did the trick for me!

                       

                      Did you actually read and try all suggestions? You don't need those checks if you use List ().

                       

                      This is a bit tiresome …

                      • 8. Re: automatically check checkbox
                        raphthepenguin

                        Yes I did read everything.

                        And I am thankful for every thought!

                         

                        I did not understand how it would be done with the List, but since It was one simple command that I was missing it wasnt a big deal to change that! And the script is running well now!

                         

                        If you believe your solution is better I am willing to give it a shot, although its working now so as far as I am concerned I am smiling again!

                         

                        Thanks!

                        • 9. Re: automatically check checkbox
                          erolst

                          raphthepenguin wrote:

                          If you believe your solution is better I am willing to give it a shot, although its working now so as far as I am concerned I am smiling again!

                           

                          It's no skin off my nose, but would you rather use a one-liner or a five-liner to achieve the same result?

                           

                          List ( x ; y ; z … ) simply creates a list from everything you feed it, ignoring empty values; so when you take the original field (which is nothing but a list in disguise) and a new value, you get a new list with everything that was in the field before, plus the new value.

                           

                          See how that is easier then scripting If/Then/Else, because, as mentioned, List () ignores empty values and puts in non-empty values in the required return-delimited format.

                          1 of 1 people found this helpful
                          • 10. Re: automatically check checkbox
                            raphthepenguin

                            I got it now...

                            Thank you I am always welcoming new ways.

                            Appreciate it!