9 Replies Latest reply on Feb 15, 2011 8:37 AM by philmodjunk

    Managing Windows

    miw

      Title

      Managing Windows

      Post

      I have two files, one is called Library and the other named Detail.  Many Detail records can link to a Library item.  Think of Library being a genre of literature and Detail as titles in that genre (Detail can only be in one genre).  Each Detail item has a link to a LibraryID.

      I have a Library layout by which I can add new titles (with limited information) via a portal on that layout.  I also have a Detail layout which can edit each item and provide much more information about an item than that available via inputs on the Detail portal on the Library layout.  Those are my two main layouts for entry.

      In my Detail layout, I want to be able to add a new Detail record directly (not using the Detail portal on the Library layout) - to do so, I need to first identify a Library for it to be attached to (something akin to the "ParticipantPicker" window in the FM Training Series FTS_Meetings database).  To do so, I open a third layout, AddOrSelectLibrary, tied to the Library table, through which I can either 1) select an existing Library for which the new Detail record will be linked to, 2) peruse the existing Library records and underlying Detail items already recorded (to be able to see if a similar record already exists) and chose one of those (a "new" record thus not be created, but an existing Detail item would be edited, say to add to the quantity), or 3) add a new library via this layout.  The AddOrSelectLibrary layout opens on top of my Detail window.  Once I select any scenario noted, the AddOrSelectLibrary window closes.

      In the instance of performing sceanrio 1, through scripting I can successfully pick an existing Library from a portal on the AddOrSelectLibrary layout, close that window and be back at my Detail layout with a new record ready to be further edited and linked to that exisitng Library.  In performing scenario 3, I can use the AddOrSelectLibrary layout to add a new Library, close that window and be back at my Detail layout with a new record ready to be further edited and linked to that newly created Library.  My problem is scenario 2; in my AddOrSelectLibrary I can choose a Library in the Library portal on that layout and below that see in a separate Detail portal all the existing Detail items already in the database.  If I see that the Detail item already exists, I want to be able to select that item, close the AddOrSelectLibrary window and have my Detail layout go to that record.  However, when I script that process (goto related record using the Detail layout), for some reason I end up with a second "Detail(2)" layout opening to that existing Detail record; the first Detail layout stays put at the last previous Detail record item.  Obviously, I do not want to have two Detail layouts open at the same time.  I can't seem to get the focus on an existing Detail item in the already open Detail layout.  Any suggestions?

        • 1. Re: Managing Windows
          philmodjunk

          Go To Related Records has a "new window" option. It sounds like you may have selected that option instead of leaving it unselected.

          • 2. Re: Managing Windows
            miw

            I doubled checked - I do not have the "Show in new window" optin checked.  I simply have "Get Related Record from: Detail" and "Show record using layout: Detail."  No result options are checked.  I tried using the "Show record using layout: Current Layout" but that did not work.  I was thinking maybe using a Global variable for DetailID, then closing the AddOrSelectLibrary layout and then bringing up the Detail record for the DetailID using the captured Global variable but I could not successfully script it to get the desired record.  Any other ideas?

            • 3. Re: Managing Windows
              philmodjunk

              I don't see how else Go To Related Records could possibly open a new window.

              Is "Detail(2)" the name of a layout or the name of the window? I assumed a window, but your original post says "layout".

              • 4. Re: Managing Windows
                miw

                "Detail" is the name of the layout.  As I already have a "Detail" layout window open when I start the process, when I make the selection under scenario 2, a second window of the "Detail" layout opens as "Detail2".

                • 5. Re: Managing Windows
                  philmodjunk

                  Then something in your script is either opening this window, or (if it already exists) bringing it to the front. If you want, you can post your script here for us to see.

                  You can copy and paste script steps by copying the script from a Database Design Report if you have FileMaker Advanced, or you can print your script to a PDF file, open the PDF and use the PDF reader to select and copy the script text for pasting here.

                  • 6. Re: Managing Windows
                    miw

                    In the Detail layout window, when I start the process for selecting a Library, I push a button with the following script:

                    SetField [Global:TempLibraryID;""]

                    Commit Records/Request []

                    Go to Layout ["AddOrSelectLibrary]

                    Show/Hide Status Area [Lock;Hide]

                    Then, now that I am in the "AddOrSelectLibrary" layout window, I can choose one of my three scenarios initially noted in my posting.  Scenarios 1 and 3 have their own script which works fine.  For my problem scenario (scenario 2), once I highlight an existing Detail record in the portal, the following script will run:

                    Close Window [Current Window]  Note:  this being the AddOrSelectLibrary window

                    Go to Related Record {From Table; "Detail";Using layout: "Detail" (Detail)]

                    That's it to the scripting; Ias I noted, I get a second "Detail" layout window that opens with the correct record noted.  The original "Detail" window remains with the latest record prior to the start of this activity.

                     

                    • 7. Re: Managing Windows
                      philmodjunk

                      There is nothing there that creates a new window named Detail(2). I suggest completely quitting FileMaker, re-opening the file and trying this process out again a single time. I think you have an extra copy of the Detail window open, which becomes the front window when your script closes the current window. If I'm right and you open the file and only run these steps a single time, you probably won't see this additional window appear.

                      I'm guessing quite a bit here, but it may be that you need an additional script step somewhere to close the Detail window once you are no longer using it so that whatever script is using New Window to open it in the first place can't create multiple copies of this window when you step through this process more than one time in a given session.

                      • 8. Re: Managing Windows
                        miw

                        I completely quit Filemaker and tried it again and got the same results - a second window for the Detail layout.  If I try your suggestion about additional scripting to avoid mulitple copies, what would such a script look like?

                        • 9. Re: Managing Windows
                          philmodjunk

                          First question, what script or scripts opens this window in the first place?

                          I think you have either one script with a new window step that does this and it's being performed twice or you have two different scripts that contain the same step.

                          You can use this test to see if the window is already opened and thus avoid opening it a second time:

                          If [IsEmpty ( FilterValues ( WindowNames ; "Detail" ) ) ]
                             New Window [//open a new window named "Detail" here]
                          Else
                             Select Window [Name: "Detail"] //Bring Detail window to front
                          End If