7 Replies Latest reply on May 25, 2015 1:37 PM by MorkAfur

    Refresh Issues with Global Variables

    MorkAfur

      Title

      Refresh Issues with Global Variables

      Post

      Not harping on why FMP should be more object oriented (at least a little), but is there a fix in Version 14 when you have a global variable referenced in an object's "HIDE WHEN" code?

      According to a FM help document I found, they recommend using "Refresh Window" when you have variables as otherwise screen components may not update properly. That's definitely what's happening in 13. (Hours spent, needlessly if I could only just send a message to a screen object to hide itself...Sorry, there I go again...).

      However, trying  "Refresh Window" has ugly flashing effects of the controls that I can't get rid of.

      Doing either Refresh Object or a Commit did not work in this case.

      Still trying to find a reason to update to 14.....no compelling reasons found yet (that would really improve my productivity or how I use the product).

      Thanks in advance for suggestions.

      - m

        • 1. Re: Refresh Issues with Global Variables
          philmodjunk

          Refresh Object would make much more sense that Refresh Window and it has worked for me in such uses. There's not enough detail in your post to see why a Refresh Object script step might fail to update things here.

          • 2. Re: Refresh Issues with Global Variables
            MorkAfur

            Thanks Phil.

            Well, I should rephrase by saying that Refresh Object works for non conditionally formatted fields, but it has the same flashing effects of HIDE WHEN when referencing, in my case, a global expression like the one below.

            Position($$ValidZips; Clients::CL_Zip; 0 ; 1) > 0 or Length(Trim($$ValidZips))  = 0

            Since I need to do a lookup to see if the entered city+state+zip is legal, the objects that will be hidden in many cases (that flash) stay on the screen until the refresh object.

            I tried even creating more variables to make sure the fields invisible by default, but this was madness trying to coordinate all the logic permutation and often counter-intuitive thinking of "HIDE WHEN" and, gulp, "Global Variables".

            -----

            BTW, the article I found I referenced above is: http://help.filemaker.com/app/answers/detail/a_id/10172/~/layout-objects-are-not-refreshed-as-expected-when-using-conditional-formatting

            Here, my conditional formatting also references a global variable (sigh) but it does not correctly refresh the zip code control (even with an update object) to have the right color. Refresh Window is the only thing that seems to correctly update the conditional formatting correctly here, per the article above. Add Flash.

            ----

            Flashing everywhere regardless of refresh object or refresh window.

            Thanks,

            - m

             

            • 3. Re: Refresh Issues with Global Variables
              philmodjunk

              I still don't see the problem nor do you describe the specific conditional formatting that you are using. Are you trying to use conditional formatting to hide/reveal objects instead of using Hide Object When or is there some other purpose to the CF? Either should work, and I don't see why Refresh Object would result in a "flash".

              Neither do I see the specific connection between that knowledgebase article and what you describe here as it refers to a very specific situation not something that is generally applicable.

              Since I need to do a lookup to see if the entered city+state+zip is legal, the objects that will be hidden in many cases (that flash) stay on the screen until the refresh object.

              So the object should be invisible until a "legal" value as assigned to $$ValidZIps?

              Don't see why that would be so difficult and you shouldn't need added variables just to make "hidden" the default status of an object.

              Position($$ValidZips; Clients::CL_Zip; 0 ; 1) > 0 or Length(Trim($$ValidZips))  = 0

              Will hide an object if the global variable is empty, only spaces or if the value in CL_Zip occurs somewhere within the global variable. Is that really what you wanted here?

              I just tested a sample file with Both a text and graphic object grouped together with a conditional format changing the color of the layout text. I had no trouble assigning a value to the global variable followed immediately by refresh object to update the visibility of the two objects with no flash like you might get with refresh window.

              • 4. Re: Refresh Issues with Global Variables
                MorkAfur

                Replies inline...

                I still don't see the problem nor do you describe the specific conditional formatting that you are using. Are you trying to use conditional formatting to hide/reveal objects instead of using Hide Object When or is there some other purpose to the CF? Either should work, and I don't see why Refresh Object would result in a "flash".

                In some cases, I'm using Hide Object to hide the zip drop down unless it's needed (user entered incorrect zip for city and state, or if a new record). The Conditional Formatting is to show red if the zip is incorrect (not in the SET VARIABLE) in the Global Variable after the SQL.

                Neither do I see the specific connection between that knowledgebase article and what you describe here as it refers to a very specific situation not something that is generally applicable.

                Since I need to do a lookup to see if the entered city+state+zip is legal, the objects that will be hidden in many cases (that flash) stay on the screen until the refresh object.

                So the object should be invisible until a "legal" value as assigned to $$ValidZIps?

                Correct. For example: Position($$ValidZips; Clients::CL_Zip; 0 ; 1) > 0

                Don't see why that would be so difficult and you shouldn't need added variables just to make "hidden" the default status of an object.

                Position($$ValidZips; Clients::CL_Zip; 0 ; 1) > 0 or Length(Trim($$ValidZips))  = 0

                Will hide an object if the global variable is empty, only spaces or if the value in CL_Zip occurs somewhere within the global variable. Is that really what you wanted here?

                The above was just an example. It's a bit complicated since there are several scenarios. I would have to send you the entire truth table for which control should be hidden and under what circumstances. The "Add Zip" button should be visible if the user enters a city and state not found but the drop down should not be since there would not be any zips in it.

                I just tested a sample file with Both a text and graphic object grouped together with a conditional format changing the color of the layout text. I had no trouble assigning a value to the global variable followed immediately by refresh object to update the visibility of the two objects with no flash like you might get with refresh window.

                Try conditionally setting the color to red based on a global variable like you did, but also then, in a SQL statement (or other dynamic variable setting, I would imagine), change the value of that global variable and see if the color changes per your global variable test. Maybe that's what you did, not sure.In my case, if the global variable changes, the color of the text does not. Refresh Object does not do it. Refresh Window does.

                Does FMP 14's cool new script environment let you do a search across all script's content? Not sure why basic Search & Replace isn't just part of FMP.

                Perhaps I have an extra Refresh Window somewhere, but I haven't been able to find it.

                Thanks again Phil,

                - m

                • 5. Re: Refresh Issues with Global Variables
                  philmodjunk

                  So far I have never seen Refresh Object produce a Flash. When  you describe using ExecuteSQL(), is this in a script step or something else?

                  If in a script step, then the method used to compute the value that is then assigned to the variable should make no difference. Whether or not the object is refreshed will make a difference.

                  So far, my tests don't show any flash an Refresh object is working to both update visibility and conditional formatting.

                  I will observe that your original sample expression was incorrect for it's stated purpose though that may not be the case in the original. I had to modify it to hide my layout object when the position function returned 0, not to hide it when the value returned was > 0.

                  • 6. Re: Refresh Issues with Global Variables
                    MorkAfur

                    Yes, the ExecuteSQL was part of a SET Variable script step. In that variable, it holds  the valid zips for the city + state.

                    I guess I need to re-download an eval copy of Developer's Assistant since FMP doesn't have the capability to search all scripts - internal to FM, as I understand it, anyway. :( That's an obvious feature the new script interface needs unless I'm wrong and it's actually there.

                    Thanks Phil.

                    - m

                    • 7. Re: Refresh Issues with Global Variables
                      MorkAfur

                      Here's the basic form elements and required interaction necessary.

                      The controls flashing only seems to happen on the layout script "On Record Load" (on Layout Enter runs the same validate script).

                      Below, I've documented the logic implemented for this -> when controls should be visible, that is. :)  The "Add Zip" button force-adds a zip that might not be in the 2012 version zip database - even for matching city and state. Did not use the USPS web service for this implementation.

                      (of course, if the city and state matches the zip entered, then all these screen controls would not be shown)

                      Thanks,

                      - m