4 Replies Latest reply on Feb 19, 2014 8:59 AM by srbridges

    Triggering a pop-up window on record load

    srbridges

      Title

      Triggering a pop-up window on record load

      Post

           In a Contacts database, I have a  ContactType field to designate if contact is "invidivual" or "business".

           If the contact is "business" I want a pop-up window to appear that shows some fields that are only pertinent to business contacts. I have a button on my layout that will correctly display the pop-up window when pressed. (The button calls a script that has only the New Window and Go to Layout steps from the script below.)

           But I want the pop-up window to automatically show when the record loads if the contact is a business...

           I have tried using this script, which I have assigned to the On Record Load script trigger on the layout setup. However this creates an infinite loop, creating zillions of pop-up windows.

             If [CONTACTS::ContactType = "Business"]

           New Window [Name: "Business Contacts"; Height:450; Width:550; Top: 200; Left: 250; Style: Floating Document]

           Go to Layout ["Business Contacts" (CONTACTS)]

           Else

             Go to Layout ["Contacts" (CONTACTS)]

           End if

            

           Can someone please tell me how to do this?

           I am using Filemaker Pro12 Advanced on Mac OS Mountain Lion. Moderate experience using Filemaker.

           Thanks.

        • 1. Re: Triggering a pop-up window on record load
          philmodjunk

               Your Script is tripping its own script trigger since New Window  will also trip the OnRecordLoad trigger.

               If [CONTACTS::ContactType = "Business" and not $$TriggersOff ]

               Set Variable [$$TriggersOff ; True ]
               New Window [Name: "Business Contacts"; Height:450; Width:550; Top: 200; Left: 250; Style: Floating Document]

               Go to Layout ["Business Contacts" (CONTACTS)]
               Set Variable [$$TriggersOff ; False ]

               Else

                 Go to Layout ["Contacts" (CONTACTS)]

               End if

               It's often a good idea to enclose all trigger performed scripts in if blocks that all check the same global variable and do nothing if the variable is true. Then any script that might trip a script trigger can set the global variable to True near the beginning of the script and set it back to False at the end to keep the script from accidentally performing triggered scripts.

          • 2. Re: Triggering a pop-up window on record load
            srbridges

                 Thank you Phil, for your reply and helpful explanation.. I would not ever have figured out using the global variable and will now go back and add that feature in other trigger performed scripts.

                 After I posted my question I did some experimenting and found that I could accomplish what I wanted by using a GTTR in new window and that eliminated using the New Window script step. But THEN (in the middle of the night) I realized that I was making it way too complicated. All I needed to do was to put the fields for individuals and the fields for business on different tabs on the same layout, name the tabs, and use a Go to Object script step based on the value of ContactType. I set the script trigger On Modify to the ContactType field, and On Record Load to the layout setup. Here's the script:  

                 If [CONTACTS::ContactType = "Business"]

                 Go to Object [Object Name: "Business"]

                 Else

                 Go to Object [Object Name: "Individual"]

                 End if

                 Can you see any reason this will get me into trouble??

                 On another problem - I recently made a post about how I somehow have made the default # copies = 3 when printing to either of my MFP, but not my laser printer.. Could you please look at that and see if you have any ideas? I am baffled...

            • 3. Re: Triggering a pop-up window on record load
              philmodjunk

                   That looks like a much better way to go. Don't see any issues with it.

                   I looked at your thread when you posted it but chose to pass on it. (I've been recovering from Pneumonia and over the last few weeks often reached a point where I didn't have the energy to tackle as many posts as I might have otherwise.)

              • 4. Re: Triggering a pop-up window on record load
                srbridges

                     Thanks - sorry to hear about your illness and hope you are soon fully recovered.