10 Replies Latest reply on Aug 20, 2013 8:29 PM by marthazink

    pulsing black outline!


      Ok, this is an odd one. To me, anyway!


      When I open my simple layout, that has a simple script trigger attached to it, I get a Pulsing Black outline of my file (FIle is on FM server). The pulsing won't stop, and eventually I have to force quit FM.


      Details -

      FMPro Advanced 12. File on Datatrium FM server

      Layout is as simple as it gets, a list of transactions, with 6 fields, all from the same table.

      Script Trigger is also simple:

      1) Open new window and give it a name

      2) Go to Layout (that same layout.)

      3) Find records with nothing in the Date Confirmed field (The layout is called Pending Transactions)

      4) Sort according to TimeStamp that is auto entered when the transaction record is created.


      That's it!


      If I delete the Sort step from the script, it doesn't do the pulsing/locking up, but it doesn't perform the find either, even thought the find is still there in the script(!)


      I ended up deleting the New Window step, and the Go To Layout step, and the Sort step, leaving only the Find step - it works fine when I go to the layout. I will leave it like that for now, but I'm just curious what the issue is. (The reason this solution is not perfect is that it doesn't open in another window, and doesn't sort)

        • 1. Re: pulsing black outline!

          It sounds like your script is stuck in a loop.


          Your "Go To Layout" script step is causing the Script trigger to run again (even though you're already on that layout, FileMaker still actively goes to that layout again).


          So your script is going to layout, then running the script trigger which goes to layout, which triggers the script trigger... etc.


          In your script trigger, add something like:


          If( $$scriptTriggersOff <> 1 )

          do stuff

          End If


          In the "do stuff" part, make sure that if you Go To Layout (same layout), set a variable so that the script trigger won't run (and make sure to set the variable back to null (""):

          To turn Script Triggers off:

          Set Variable [ $$scriptTriggersOff ; 1 ]


          To turn Script Triggers on:

          Set Variable [ $$scriptTriggersOff ; "" ]


          Hope that helps!

          • 2. Re: pulsing black outline!

            Martha is correct, as evidenced by your first two steps:


            1) Open new window and give it a name

            2) Go to Layout (that same layout.)


            Whenever you open a new window, any OnLayoutEnter triggers will fire. Hence, your triggered script does this:


            1) Open new window

            1a) Trigger fires

              1a.1) Open new window.

              1a.1a) Trigger fires.

                1a.1a.1) Open new window.

                1a.1a.1a) Trigger fires.

                  1a.1a.1a.1) Open new window.

                  1a.1a.1a.1a) Trigger fires.


            Repeat until force quit or until FileMaker crashes.       


            Martha's solution will fix the problem.



            1 of 1 people found this helpful
            • 3. Re: pulsing black outline!

              Very helpful guys - thanks! I should have thought of that!

              I'm still not 100% clear on the instructions for the fix, but I'll work on it!!


              • 4. Re: pulsing black outline!

                Here is my example.


                See attached file.

                1 of 1 people found this helpful
                • 5. Re: pulsing black outline!

                  This is what is on the file you shared:


                  Enter Browse Mode

                  If [ $$first_time ] Exit Script [ ]

                  Set Variable
                  [ $$first_time; Value:1 ]

                  End If

                  Go to Layout [ “rpt_weekly” (mnt_renewal_rates) ]

                  Sort Records [ Keep records in sorted order; Specified Sort Order: mnt_renewal_rates::region; ascending ] [ Restore; No dialog ]

                  Refresh Window

                  [ Flush cached join results; Flush cached external data ] Set Variable [ $$first_time; Value:"" ]


                  I know that "$$" is a 'global variable', but with apologies for the dumb question, What is that? What does it do? or What is it doing in this script? (hoping you answer the question I need to ask, because I'm guessing at which question to ask...;))


                  I need a Find before the Sort, that seems simple enough...


                  I think the script is saying:

                  If it's the first time you've run this script then exit the script, If not, then  "Set Variable [ $$first_time; Value:1 ] "

                  I do not know what that means...


                  Refresh window, that looks like a good thing to do to increase speed of the file??


                  Again, sorry for the dumb questions...

                  • 6. Re: pulsing black outline!

                    All good questions!


                    So a global variable is something that can be set and will "survive" or exist after the script ends. A local variable "$" only lasts until the script ends (and doesn't exist from one script to another).


                    The first time you enter the layout, the script trigger will trigger.


                    Enter Browse Mode

                    Go To layout (same as current layout) - which triggers the script trigger again


                    So how do you tell the script not to run again? You set a global variable (something that will live outside of the script) as a flag, to tell the script trigger not to actually run again.


                    On the first time the script trigger runs, set the flag $$first_time to 1.

                    When the script reaches Go To layout (same as current layout), the script trigger will be triggered. However, now the script trigger sees that $$first_time is set to 1. Based on the If statement, the script will exit and you won't get stuck in an infinite loop.


                    I think the best way to think of $$first_time is as a flag that stops the script trigger from running over and over again. As long as that flag is turned on, the script trigger will just exit. Once you're done, you turn the flag off, so that the script trigger will properly trigger in the future. It's just a temporary flag to avoid getting stuck in a loop.

                    • 7. Re: pulsing black outline!

                      Slight correction: Go to Layout will not cause the OnLayoutEnter trigger to fire if the destination layout is the same as the current layout.


                      Otherwise, good stuff.   

                      • 8. Re: pulsing black outline!

                        Ok, I'm getting that a variable in FM is lot like the clipboard when you copy and paste. If it has 2 $$ it is global, it exists past the current script, until... you use it somewhere?   Why the words "first_time"? does FM recognize them to mean the first time you are doing something? first time since when?

                        1 means Yes?


                        Honestly I wouldn't blame you if you give up on me, but I sincerely would like to understand it.


                        Thanks much!



                        • 9. Re: pulsing black outline!

                          No giving up


                          The global variable exists until you either change the value, clear the value, or close your session.


                          The name is completely decided by the developer. You could call it $$ScriptTriggerOff or $$DontRunTrigger or $$FirstTime or anything you want. Basically, you're naming a variable whatever you want and then you reference that variable by the same name.


                          Imagine opening up a file and the opening script sets a global variable ($$startTime) to Get(CurrentTime). Let's say you open it at 9:31am.


                          At any point during that session (anytime before you close the file), you could run a script that shows the user the value in $$startTime, which would be 9:31am.


                          Have you used fields set to be global? They can serve a similar purpose. It's a place to store something temporarily.


                          As for your question about 1 = Yes: It's common for developers to use 1 to mean "yes" or "true" but if you wanted to, you could set the value of the global variable to the word "yes". Basically, you're setting a global variable to some value, and you check for that value in an if statement to run certain script steps based on the scenario.

                          • 10. Re: pulsing black outline!

                            Huh. For some reason I thought it would run again. Woops! Thanks for the correction!