5 Replies Latest reply on Jan 6, 2009 3:27 PM by Jens Teich

    Related Record info to exsiting window



      Related Record info to exsiting window


      Scenario: I have a main window open "Window 1" and a second smaller window "Window 2". I create a "Get Related Records" search in Window 2 and want the results to be displayed in Window 1. 


      What I did: In Window 2, I created a button on a particular file that when clicked executes a script "GetMyRelatedRecords". Very simple script:


      Select Window [Name: "Window 1"] 

      Go to Related Record [Show only relatedrecords; From table:"Window 1"; Using layout: "List View" (Window 1)] 


      Outcome: Window 1 is activated and switches to  List View and finds related records. Only executed right the first time and has not done it again. It keeps giving me the result of that first time. When I move the "Select Window" statement to be after the "Go to .." statement. It always gets me the correct listing but, in Window 2.


      I quit FM9 and opened the database several times. Now all I get in Window 1 is the listing of all the records using the same original script that executed right once in the very beginning. I get the same listing of all records all the time now in Window 1. Of course except when I move the "Select Window" statement to be after the "Go to .." statement. It always gets me the correct listing but, in Window 2.


      I guess I'm missing a step or two here. Any help would be greatly appreciated?? Thanks ..

        • 1. Re: Related Record info to exsiting window



          Thank you for your post.


          Having two separate windows allows you to see two different views of the same table.  Window 1 may display record 1 in one layout, and Window 2 may display record 2 in another layout.  The two windows are totally independent of one another.


          If you are in Window 2 and displaying record 2, when you switch to Window 1 and go to related record, you are going to the related record associated with record 1; not record 2.


          In your script, you may want to store a key field to a variable, then when you switch to Window 1, then use the variable in a find to locate that record and then go to the related record.  Does that make sense?


          Let me know if you need clarification for any of the above steps.



          FileMaker, Inc. 

          • 2. Re: Related Record info to exsiting window

            TSGal, thanks for the suggestion on storing a variable to be searched on the second window. That makes good sense, but that was what I didn't want to do (create a field for just that purpose). I thought there might be a simpler selection in the Script Maker window such that I didn't have to search to store a variable to then search it to restore the find and finally delete the variable.


            Instead of storing the variable, can I just pass it to the next window and complete the search in one script. Something like:


            1)  While in Window 2 click button to set variable = to current file field name "myField"

            2) SelectWindow 1

            3) Find records where field name = variable and list in layout named "ListView" 



            Note: I always want to have Window 2 only displays records from Table 2 and Window 1 only display records from Table 1. Kinda like floating pallets that have one purpose each. The form I'm creating is a multiuser form and I don't want a field populated with a value that could cause another person to get unexpected search results in the event that two persons do a search at the same time. The variable's value would only exist in the script of a particular users computer for that user's search.


            Thanks again ... 

            • 3. Re: Related Record info to exsiting window
              Jens Teich
                 It is not easy to achieve what you try to do and it is even harder to control everything in such a setup.

              What happens if user closes one of the windows? You always have to check wether the windows are still there.

              Worse: what happens if user starts new windows?

              And so on ...

              I tried this and finally decided not to go this road.


              • 4. Re: Related Record info to exsiting window

                The set up is for a well established way of working here. If the user closes Window 2, he/she knows that they shall click on the provided link to re-open window 2. If the user is closing Window 1, the main user window, that means he is done doing what he/she came to do ... 


                It may be that I need an "If window exists otherwise create it statement" ... 


                The users can start new window, if they please but they will always come back to Window 1 and 2 since they would be the most relevant.


                We are talking about typical everyday users who don't care too much to poke around and see if they can break anything. They just want to do what they came to do and quit the application.


                It may be that I need a script that closes all the windows when the main window is closed ...


                This is for a closed focused group. If I were to port it over to the general public, I would have to more seriuosly consider your observations ...


                What about my question about passing a variable value ?? Any thoughts ... 


                Thanks for taking the time to post, much appreciated ... 


                -- Ponce 

                Uncertified Developer ;) 

                • 5. Re: Related Record info to exsiting window
                  Jens Teich
                     I recommend closing the second window and reopening with GTRR. This is a two line script and so fairly easy.

                  Disadvantage is some flickering.