10 Replies Latest reply on Oct 24, 2014 6:13 PM by user19752

    Hide object when, when is it evaluated?

    planteg

      Hi,

       

      on a layout, I wish to tell the user if some field have been modified. To implement that I have a Text object that I wish to hide when there are no modifications pending. Hide object when is set to Get (RecordOpenState) = 0.

       

      What I expect is that as soon as field is modified, the Text object will be visible. That's Ok if I need to go to a different field. This is not what I get.

       

      Since it didn't seem to work, I added a button that tells the value returned by Get (RecordOpenState). So I start editing a field and hit the button. I am told that the value is 2, so the Text object should now be visible, but it's not. I continued to search for and discovered that I need to cancel a commit for the field to appear - I have scripts that prevent an auto-commit when clicking outside a field.

       

      It looks like the calculation for the field is triggered only when I cancel the commit.

       

      Someone can explain that behavior ?

       

      Thanks

        • 1. Re: Hide object when, when is it evaluated?
          keywords

          In Filemaker Help it says of Get ( RecordOpenState ) that it returns:

           

          0  for a closed or committee record

          1  for a new record that hasn't been committeed

          2  for a modified record that hasn't been committed

           

          A quick check suggests that the hide condition is not evaluated at all as long as there are uncommitted changes on the record. That being the case, your hide condition cannot work.

          • 2. Re: Hide object when, when is it evaluated?
            jormond

            Does it work if you base the hide condition on a variable? You could then use the OnObjectModify script trigger to set the variable.

             

            Edit: Did a quick test. This is how I got it to work. Note you could probably use the Get ( RecordState ) here as well.

             

            Script = "Set Show Variable"

            • Freeze Window //forces a redraw when the script is finished.
            • Set Variable [ $$show ; Get ( ScriptParameter ) ]

             

            Script Triggers

            • On fields: OnObjectModify [ Script: Set Show Variable ; Parameter: 1 ]
            • On layout: OnCommitt [ Script: Set Show Variable ; Parameter: 0 ]

             

            Hidden Object

            • Hide Object when [ $$show = 0 ]

             

             

            To use the Get ( RecordOpenState ) I did this.

             

            Script = "Refresh Window"

            • Freeze Window //forces a redraw when the script is finished.

             

            Script Triggers

            • On fields: OnObjectModify [ Script: Refresh Window ]
            • On layout: OnCommitt [ Script: Refresh Window ]

             

            Hidden Object

            • Hide Object when [ not Get ( RecordOpenState ) ]
            • 3. Re: Hide object when, when is it evaluated?
              planteg

              keywords,

               

              A quick check suggests that the hide condition is not evaluated at all as long as there are uncommitted changes on the record.

               

              This is very unfortunate, that means a lot of use for hide condition are not possible at all. I tried to use conditional formatting instead, same result. Strangely, if I cancel commit via a script attached to onRecordCommit, then the condition is evaluated and the visibility is updated. Weird .

               

              Joshua.

               

              that would mean an onObjectModify to all of the fields, quite a heavy solution. But then, if like says keywords the condition is not checked if there are uncommitted records, the value of the variable will not be checked.

              • 4. Re: Hide object when, when is it evaluated?
                jormond

                What you need is something to refresh the window when you set the variable or field.

                 

                See my update. A simple "Freeze Window" script is all you need.

                • 5. Re: Hide object when, when is it evaluated?
                  planteg

                  Joshua,

                   

                  I should have search the Web a little bit .

                   

                  On this page http://help.filemaker.com/app/answers/detail/a_id/11969/~/hiding-or-showing-layout-objects-in-filemaker-pro-based-on-a-specific-condition FileMaker specifies that

                   

                  The "hidden" condition of a layout object is evaluated when the record / layout is brought into view.  If conditions change and a layout object should be hidden or displayed, the layout must be manually updated to reflect the new visibility state.  This can be accomplished by using the (new)Refresh Object script step, or the Refresh Window script step.

                   

                  So you were right. I don't need to use a variable. All I need to do is call RefreshWindow - this way it works for any layout ! - in a script link to onObjectModify. I just wonder if RefreshObject (new in FM 13) could be faster than RefreshWindow.

                   

                  Just one thing, but that's not a big matter: if one cancel changes to a field, the RecordpenState does not go back to 0.

                   

                  Thanks

                  • 6. Re: Hide object when, when is it evaluated?
                    Mike_Mitchell

                    Revert Record puts the RecordOpenState back to 0.

                    1 of 1 people found this helpful
                    • 7. Re: Hide object when, when is it evaluated?
                      BruceRobertson

                      "I just wonder if RefreshObject (new in FM 13) could be faster than RefreshWindow."

                       

                      Yes.

                      1 of 1 people found this helpful
                      • 8. Re: Hide object when, when is it evaluated?
                        jormond

                        I totally forgot about the Refresh Object. Thank you sir.

                        • 9. Re: Hide object when, when is it evaluated?
                          keywords

                          Joshua, thanks for going further than I did in my test and showing that my initial thought (the hide condition is not evaluated at all as long as there are uncommitted changes) is wrong. Just a couple of further observations on this in light of your posts:

                           

                          1.     Using the single Freeze Window script step works perfectly when activated by OnLayoutKeystroke

                          2.     I tried the Refresh Window instead: that also works, but only on the second keystroke

                          3.     I tried using Refresh Object instead: as above, only works on the second keystroke

                           

                          An interesting further observation about keystrokes. With the Freeze Window option, the tab key, even though its use triggers the script, does not alter the RecordOpenState so the hide condition is not met (I am using Get (RecordOpenState) ≠ 0). However, with either of the Refresh script options the tab key will alter the RecordOpenState and hence the hide condition when it is the second keystroke.

                          • 10. Re: Hide object when, when is it evaluated?
                            user19752

                            Another consideration is, OnLayoutKeystroke fires only when modified using keyboard, so no effect for using mouse.

                             

                            Changing expression like as

                            Evaluate ( "Get ( RecordOpenState ) = 0" ; [ field1 ; field2 ] )

                            affect both key and mouse, but that occurs on onSave or onModify timing.

                            (hmm ? drag&drop in a field and paste with mouse both fires modify trigger , but only d&d cause calculate ??)

                            Most bad thing is need to list all fields.