4 Replies Latest reply on Oct 22, 2014 1:01 AM by lijnbach

    "Show" or "Hide" buttons or fields based on Get (RecordOpenState) not working properly

    lijnbach

      Summary

      "Show" or "Hide" buttons or fields based on Get (RecordOpenState) not working properly

      Product

      FileMaker Pro

      Version

      13.03v3

      Operating system version

      OSX 10.9.5

      Description of the issue

      Showing or hiding buttons or fields based on Get (RecordOpenState) not working properly.

      Steps to reproduce the problem

      Have a look at this discussion with PhilModJunk:

      http://forums.filemaker.com/posts/f3ece48ccf

      Have a look at the last reaction of PhilModJunk (last paragraph).

      A testfile is included in my post

      Expected result

      Hide button when value Get (RecordOpenState) changes in 2 (Edit Mode)

      Actual result

      Not hiding (updating) the button, also not after refresh object.

      Workaround

      If is use a variable based on Get (RecordOpenState) to hide or show the button it works fine.

        • 1. Re: "Show" or "Hide" buttons or fields based on Get (RecordOpenState) not working properly
          TSGal

          Hans Lijnbach:

          Thank you for your post.

          Get (RecordOpenState) is intended for script usage, and the value will update a button after a refresh is issued.  This is as designed.

          Setting a variable is correct, but as PhilModJunk pointed out, using OnLayoutKeystroke does not guarantee this will edit a record.  Instead, consider using OnObjectEnter script triggers.  Entering the field will then hide the button, even though RecordOpenState is 0.  Once a change is made to a field, then RecordOpenState will change to 2 (or 1 for new records).

          TSGal
          FileMaker, Inc.

          • 2. Re: "Show" or "Hide" buttons or fields based on Get (RecordOpenState) not working properly
            lijnbach

            Thanks for your reply,

            No matter the discussion I had with PhilModJunk, the problem is, also after "a refresh" the button does not update. PhilModJunk has tested this also. This was the original problem. It is no disaster because I use a variable as workaround. But, if I have a button with "hide if Get (RecordOpenState) = 2", the button does not hide when editing a record. Also not after a refresh button. (It does hide, but only after a second keystroke).

            The reason I did not use the "OnObjectEnter" trigger, is because I then have to that for every field I am using. I only use the "OnLayOutKeystroke" to refresh the button. 

            Hans Lijnbach.

            • 3. Re: "Show" or "Hide" buttons or fields based on Get (RecordOpenState) not working properly
              TSGal

              Hans Lijnbach:

              Keep in mind that an OnLayoutKeystroke script trigger is fired when the keystroke has been pressed; not the result of the keystroke.  The result of the keystroke occurs after the script has been completed.  Therefore, the result of Get(RecordOpenState) will be 0 at the time the script is triggered, and then 2 when the script completes.  Therefore, setting the variable within the script is the correct method.

              To handle the issue if the keyboard is pressed before entering a field, you may want to change the script to:

              If [ Length ( Get ( ActiveFieldName ) ) > 0 ]
                 Set Variable [ $$Button ; Value: 2 ]
              End If

              If you change the Set Variable step to Value: Get (RecordOpenState), this will set $$Button to 0, and when the script completes, RecordOpenState will return 2.

              TSGal
              FileMaker, Inc.

              • 4. Re: "Show" or "Hide" buttons or fields based on Get (RecordOpenState) not working properly
                lijnbach

                O.K. Thanks for the explanation,

                I expected the result of the keystroke before the script started. But the result comes after the script. So, that explains why the "hide if  Get (RecordOpenState) = 2" reacts after the second keystroke, and "hide if $$Button = 2" reacts immediately.

                The way I am handling it now, with the variable works just fine. And I like this function because it is an indicator what the user is doing, and it gives a opportunity to show or hide fields or buttons, depending on what the user is doing.

                Sorry if I made mistakes in my English, but my native language is Dutch.

                Hans Lijnbach