6 Replies Latest reply on Jul 8, 2013 4:16 PM by deathrobot

    Trouble with onObject script trigger

    deathrobot

      Title

      Trouble with onObject script trigger

      Post

           I have a boolean field I'm using as a checkbox (non-zeros are "x", zeros are ""). The checkbox should only be available to the user if a field ("checkField") is empty. I'm using conditional formatting to hide the checkbox if checkField contains data. However, even though it's invisible it's still possible to set the checkbox to "x". I wrote a simple script that looks at the checkField, and if it contains data sets the checkbox to "". This works fine when calling the script manually, but I'd like to attach it to the boolean field itself so that if a user sets it to "x" when it should't be, it just sets itself back to "". I've tried every onObject script trigger, but none of them will trigger the script. I seem to be missing something, but am not sure what it is.

           Thanks,

           Michael

        • 1. Re: Trouble with onObject script trigger
          schamblee

               OnObjectModify will trigger each time the checkbox is modified.

          • 2. Re: Trouble with onObject script trigger
            deathrobot

                 Thanks for your response, S Chamblee. That's the script trigger I currently have set up, but it doesn't work! I must be doing something elsewhere that is interfering with this working properly. Here's more info:

                 - checkbox is called "booleanCheckbox"

                 - booleanCheckbox is a button that sets itself with this calc:
                      Table::booleanCheckbox xor True

                 - booleanCheckbox has two conditional formats:

                   
            1.           formula: Self = True; set fill green
            2.      
            3.           formula: not IsEmpty ( Table::checkField ); set text color orange and fill transparent

                 - script is:
                      If [not IsEmpty (Table::checkField) ]
                           Set Field [ Table::booleanCheckbox; "" ]
                           Go To Field []
                      End If

                 Not sure if any of this sheds more light on the situation.

            • 3. Re: Trouble with onObject script trigger
              philmodjunk

                   Use a script parameter with your script trigger to pass the current value (before the mouse click modifies it) of the field to the script. THen, you can uset Get ( ScriptParameter ) to reset the field back to the original value.

              • 4. Re: Trouble with onObject script trigger
                deathrobot

                     Thanks, PhilModJunk. The trouble I'm experiencing does not have to do with storing the current value; the decision to "uncheck" the boolean field is based on a calculation that looks to see if a different field ("checkField") is empty or not. If it is not empty, the script trigger should set the boolean checkbox to "". However, your reply made me realize that the script was running BEFORE the field was actually checked, so would not work as intended. I thought this might fix things:

                     New Script called on onObjectModify:

                     If  [ not IsEmpty ( checkField ) ]
                          Exit Script [ Result: False ]
                     End if

                     My thinking was that if the test were true, it would nullify the user having checked the box. No luck, though. The only thing that IS working is running this script manually:

                     If  [ not IsEmpty ( checkField ) ]
                          Set Field [ Checkbox ; "" ]
                     End if

                     It doesn't work from a script trigger. Any other ideas?
                      
                     Thanks,
                     Michael
                      
                • 5. Re: Trouble with onObject script trigger
                  philmodjunk

                       Make the field a button and don't use a script trigger. Button setup... can be used to turn nearly any layout object, including fields into a button that performs a script when clicked/tapped.

                  • 6. Re: Trouble with onObject script trigger
                    deathrobot

                         Should have thought of that before. It was already a button. Just added the if statement and it works now.

                         Thanks very much!

                         Michael