5 Replies Latest reply on Jul 1, 2016 1:35 PM by lognalwal

    On Object Script Behaviour - Check Box Field

    MartinCrosman

      I am hoping someone can help me.

       

      I have a script that capture the value of fields that is tied to an object script step. Works fine until I get to a field that is formatted as a check box.

       

      Lets say the field displays one checkbox value = Retired. The checkbox is checked as Retired.

       

      If I tab into the field the value Retired is captured. If I click directly into the field the checkbox toggles to empty instead of the orginal value of Retired and the value onboject entry is nothing. I thought it would return that the value on enter was Retired.

       

      Any work around for this? Is this expected behaviour?

       

      Thanks

       

      Martin

        • 1. Re: On Object Script Behaviour - Check Box Field
          Mike_Mitchell

          Martin -

           

          The OnObjectEnter trigger fires after the event (see http://www.filemaker.com/12help/html/script_trigg.38.2.html#1029602). I would surmise (someone will correct me if I'm wrong) that clicking the checkbox is processed before the focus is changed to the checkbox field. Hence, the order of events probably looks something like this:

           

          1) User clicks the checkbox.

          2) Checkbox value is toggled.

          3) Focus lands in field.

          4) Trigger fires.

           

          To work around it, I suggest you change the field to a button that runs a script. The script can do something like this:

           

          Go to Field [ MyField ]

          # Script trigger fires here

          Set Field [ MyField ; Case ( MyField = "Retired" ; "" ; "Retired" ) ]

           

          HTH

           

          Mike

          • 2. Re: On Object Script Behaviour - Check Box Field
            MartinCrosman

            Thanks Mike

             

            You got me thinking. So if the check box field (Retired) had mutilple values how would I capture these initial values.

             

            If I took your approach of making the field (Retired) a button that would run this script:

             

            Go to Field (Result)

            Set field(Result;Retired)

            Go to Field (Retired)

             

            and then I can modified the result and the initial values are included.

            • 3. Re: On Object Script Behaviour - Check Box Field
              Mike_Mitchell

              As soon as you go to the field, your initial values are captured by your triggered script, are they not?

               

              In such a case, you would do something like this:

               

              Go to Field

               

              1. Begin triggered script

                Set Variable $$originalValue ; table::Retired

              1. End triggered script

               

              Set Field [ Retired ; Case ( not IsEmpty ( FilterValues ( $$originalValue ; "Retired" )) ; Substitute ( $$originalValue ; "Retired" is a carriage return.

               

              This would add the value "Retired" to the end of the list if it's not already there, and remove it if it is, while preserving the rest of the original value.

               

              HTH

               

              Mike

              • 4. Re: On Object Script Behaviour - Check Box Field
                MartinCrosman

                I dropped on the OnObjectEnter trigger as it really isn't doing what I want.  I don't want the value of the checkbox field to be altered when user clicked in the field. Your button work around approach is great as I just want the existing value as it was before the user clicked in the field. So having the button set the Result field to the value of the Retired field is fine. Then by placing the user in the Retired field they can alter the values if they wish.

                 

                 

                Thanks again

                • 5. Re: On Object Script Behaviour - Check Box Field
                  lognalwal

                  I do not know if this is a better work around, but I created a set of steps at the end of my trigger script that copies the contents of the checkbox field to another "copy field" using SetField. So the "copy field" will always contain the current contents of the checkbox field before it is clicked. The "copy field" can then be used to compare (using PatternCount) to the checkbox field. This way the script "knows" if I am deselecting or selecting. Let me know if further explanation is needed. Hope this helps.