13 Replies Latest reply on May 31, 2012 4:41 PM by philmodjunk

    Go to related record doesn't work

    AnitaWoods

      Title

      Go to related record doesn't work

      Post

      I am a novice FM user, with a db for my home business as a midwife.  I have never been able to get "go to related record" to work.  I typically use this in a button setup.  I have a Home layout with a list of current clients, based upon TablePregnancy2, with a button that is supposed to GTRR in the layout LOPrenatalChart, also based upon TablePregnancy.  I have a relationship from TablePregnancy to TablePregnancy2.  The button setup lists "get related record from: "TablePregnancy", show record using layout "LOPrenatalChart".  I have tried it multiple ways, "show only related records; match current record only" and "match all records" and with nothing checked in the result options, or with "show in new window".  It never works.  It just takes me to the prenatal chart layout and shows all the records, with the first record displayed.  I have another layout, LOFiles based upon TableFiles with a relationship from TableFiles to TablePregnancy, and the GTRR goes from TablePregnancy, show record using layout LOPrenatalChart. It never goes to the related record, just shows the layout with all the records and the first record is displayed.  What am I doing wrong?

        • 1. Re: Go to related record doesn't work
          GuyStevens

          Where is your button located?

          If you have a list I'm assuming you are in a list view. Is your button in the body?

          If you could give us some screenshots we might ba able to see what we are talking about.

          I use GTRR pretty often, never had any problems with it.

          • 2. Re: Go to related record doesn't work
            philmodjunk

            "get related record from: "TablePregnancy", show record using layout "LOPrenatalChart"

            Try From "TablePregnancy2"

            GTRR should refer to a different table occurrence than the one on which your current layout is based.

            Think of it this way:

            If you had a portal to the records you want to use GTRR in order to bring them up on a layout, the "From table:" part of GTRR should refer to the table occurrence listed in "show Related Records from" in portal setup, not the table occurrence shown in "Show Records From" in Layout Setup...

            • 3. Re: Go to related record doesn't work
              AnitaWoods

              I am not using a portal.  Button is in the body, in list view.  Screen shot attached (I whited out the names in Photoshop).  The button is on the Home layout based upon TablePregnancy2.  The button setup refers to "get related record from TablePregnancy" on LOPrenatalChart.  When I switched it to "get related record from TablePregnancy2, it does the same thing.  Goes to the layout, shows all records with the first record displayed.  If I switch it the other way around, I get the same result. 

              • 4. Re: Go to related record doesn't work
                philmodjunk

                I know you are not using a portal, but if you can set up a portal to display the records you want to pull up with GTRR, then you have a relationship that will work with GTRR and you would specify the portal's table occurrence in the GTRR's "table" parameter--not your layout's. It's a way of understanding how the relationship on which GTRR relies must be set up in order for it to work.

                What is the relationship between TablePregnancy and TablePreganancy2? Are these two occurrences of the same data source table or completely different tables?

                If you have something like this:

                TablePregnancy2::ID = TablePregnancy::ID

                then this is the GTRR call you should have to pull up just the one record clicked on the other layout:

                Go To Related Record [Show only related records; From table: TablePregnancy; Using layout: "LOPrenatalChart" (TablePregnancy)]

                 

                • 5. Re: Go to related record doesn't work
                  AnitaWoods

                  Two occurrences of the same data source table.  I have attached a pic of my relationships.  I don't know what to say, I feel like I've got it exactly like you say, and it just doesn't work.  Anyone willing to view a clone?

                  • 6. Re: Go to related record doesn't work
                    philmodjunk

                    As a test, put a portal to Pregnancy 2 on your above layout (the one based on Pregnancy).

                    Do you see any records in the portal?

                    If you don't see any records in the portal, then there's a problem with your relationship and there are no related records. And that fits the results you are getting.

                    Matching by 2 pairs of fields, PregnancyID and EDD Value list is not a relationship that makes sense here. If PregnancyID is an auto-entered serial number, then you should remove the EDD Value List from the relationship.

                    • 7. Re: Go to related record doesn't work
                      AnitaWoods

                      The test portal produced only one record: the first record in the prenatal chart layout, which is always where the GTRR takes me.

                      Yes, PregnancyID is autoentered serial number.  EDD Value List is a separate relationship that must be there in order for a different field to work on another layout.  I can't remove that one.  (See post http://forums.filemaker.com/posts/924dc1e829 for the basis of that relationship.)  So as another test, I created yet a third occurrence of the TablePregnancy, with only PregnancyID related.  (It is confusing, but LOPrenatalChart is based on the TablePregnancy, and LOHome is based on TablePregnancy2.)  So I changed LOHome to being based on TablePregnancy3, then tried to make the GTRR work with the new third table occurrence.  It still doesn't, but still takes me to the first record in the LOPrenatalChart and shows the same 10 records as in the Home layout.

                      • 8. Re: Go to related record doesn't work
                        philmodjunk

                        EDD Value List is a separate relationship

                        It's not a separate relationship, it's part of the same relationship where records match by both the list of values in this field and the ID number. As this is a self join, I don't see how that will work as the ID field already uniquely identifies each record. Assuming that PregnancyID is a serial number field that uniquely identifies each record in this table, including it in the relationship will limit you to exactly one matching record no matter what values exist in the EDDValueList field. The other thread does not show matching by ID's and the EDDValuelist, just matching by the EDDValue list.

                        You aren't limited to this one relationship, you can add more occurrences of pregnancy with different pairs of match fields so that you only match by ID's and only by EDDValue list if that's what you need...

                        The test portal produced only one record: the first record in the prenatal chart layout, which is always where the GTRR takes me.

                        This indicates that GTRR is doing exactly what it is designed to do. If you want it to go to a different record, you need to define a different relationship. What records were you expecting to see in this portal? Once you have a relationship that lists the records you need in the portal, you can remove it and use GTRR with a reference to the portal's table occurrence to bring up the records that you want.

                        • 9. Re: Go to related record doesn't work
                          AnitaWoods

                          Thank you for all your help, PhilModJunk.  For the EDD value list, having BOTH the value list and the ID number related is essential to making the EDD Value List work.  I can't remove the two relationships in that table occurrence.  If you think info on how pregnancy works is TMI, skip the rest of this paragraph.  If it helps to understand WHY this relationship must have two joins: every pregnant woman can have more than one due date for any pregnancy.  One based on her last menstrual period, one based on the date of conception, one based on what the ultrasound indicates, or one declared from a variety of guesses.  So each client in my db for each pregnancy can have more than one option.  Thus each PregnancyID can have four options for an Estimated Due Date (EDD).  Each client in the db may have more than one pregnancy though, as they come to repeatedly for future babies.  So when I want one EDD to appear for a client, I have a value list that shows the four available dates for that client.  Thus choosing an EDD from four options for each client for a particular pregnancy needs the double relationship to make that value list work.

                          Getting back to GTRR, I created a third occurrence of the Pregnancy table, Pregnancy 3, related to Pregnancy by ID only, and changed the Home layout to be based on Pregnancy 3.  Still doesn't work.

                          "What records were you expecting to see in this portal?"

                          Well, when you look at the photo of the Home layout above, for example if I click on the "Go" next to the record that begins with "Je", I expect it to take me to the PrenatalChart layout and show me Je's record.  Or if I click on Go next to "Sa", I expect it to take me to the Prenatal Chart showing Sa's record.  It doesn't do that.  No matter what "Go" I click on, it takes me to "A"s record (the first record in the table).  I'm frustrated in why even a third occurrence of the table wouldn't be enough to make the GTRR work. 

                          • 10. Re: Go to related record doesn't work
                            philmodjunk

                            Getting back to GTRR, I created a third occurrence of the Pregnancy table, Pregnancy 3, related to Pregnancy by ID only, and changed the Home layout to be based on Pregnancy 3.  Still doesn't work.

                            If you have Pregnancy linking to pregnancy 3, base your home layout on pregnancy. If you have Pregnancy 2 linking to pregnancy 3, base your home layout on pregnancy 2. In both cases, specify Pregnancy 3 as the Table: parameter in the GTRR script step.

                            • 11. Re: Go to related record doesn't work
                              GuyStevens

                              If you are having trouble using the GTRR function, maybe have a look at this demo file:

                              http://dl.dropbox.com/u/18099008/Demo_Files/Pregnancy_GTRR_2TO.fp7

                              It's really basic.

                              • 12. Re: Go to related record doesn't work
                                AnitaWoods

                                BREAKTHROUGH:  In doing more troubleshooting, I found the GTRR was working perfectly on every other layout except for the Prenatal Chart.  So there is nothing wrong with my GTRR code or relationships.  In trying to find out why it is only that layout that causes the problem, I discovered the problem is a script trigger for the Prenatal Chart layout: OnLayoutEnter: a script that omits any record with a particular field that is not null.  What would make that script cause the GTRR to not work?

                                • 13. Re: Go to related record doesn't work
                                  philmodjunk

                                  Well, your GTRR script will trip that trigger every time unless you modify the triggered script so that you can selectively turn it on and off.

                                  I do it this way:

                                  I write my trigger controlled scripts so that they are inside this If block:

                                  If [ Not $TriggersOff ]

                                  # put rest of script here

                                  End IF

                                  Then, in a script where I don't want trigger controlled scripts to interfere, I do this:

                                  Set Variable [$$TriggersOFF ; Value: True ]

                                  #put rest of scritp here

                                  Set Variable [$$TriggersOff ; value: False ]

                                  If you are using a single step button option, you'll need to write a script that combines the GTRR with the above code and set your button to perform that script.