4 Replies Latest reply on May 10, 2017 10:13 AM by philmodjunk

    Go To Related Record not taking me to the correct record



      Apologies if this question has been answered already elsewhere. I've been using the "Go to Related Record" function (both within a script, and as a single action button).


      Recently, it's not been working correctly. It takes me to the correct layout, but not the correct record.


      For example, in the screenshot, no matter which "event record" I click go next to on 04/05/2017, it always takes me to the 1st event record in that portal (in this case, Matthew Halsall).


      I've investigated the following

      1. Checked that the GO button is performing the correct script (GRR_BOTW2_Functions_Production_0031).
      2. Re-configured the button from a script to a single Go to Related Record action.
      3. Checked that in both cases the Go to Related Record is taking you to the correct table (events).
      4. Checked that the button is embedded correctly in the portal, i.e., moved the button inside the portal and tested dragging the portal to check that the button moves with the portal.
      5. Checked that the event fields are also inside the portal and are moving with the portal.
      6. Tried moving the button so that none of its edges are touching the edge of the portal.
      7. Checked the sort order of the portal and tried unchecking the sort portal records in case that made any difference.
      8. Went into the relationships graph and checked that both relations of the key linking Dates to events (i.e., Dates --> Dates_Events --> Events) are not sorted.
      9. Checked other layouts in which this diary view occurs and it is happening elsewhere.
      10. Checked the File Options.
      11. Checked that all affected layouts don't have other script triggers running that interfere with anything. At the moment, they only have a Set Variable Script trigger (used in a "Backwards" script) - which shouldn't affect it.


      I'm using Filemaker Pro v14 on a server-hosted solution. It's quite a large, old solution (est. 2012) so I'm wondering whether it's something to do with indexing and maybe the file has reached its capacity? If that's the case, is there a way to clean out indexing? If that's not likely to be the issue then my apologies, or whether it's a bug with v14, but I can't think of any other reason why the Go to Related Record wouldn't be taking me to the correct record as it's only started doing this recently.


      Many thanks,

        • 1. Re: Go To Related Record not taking me to the correct record

          The script step is behaving correctly.


          When you go to related record(s) (note the plural), it will take you to a found set of ALL the records in the portal that are related. Per the documentation:

          Show only related records creates a new found set in the related table with the options either to match the current record or to match the entire found set. The first record in the found set becomes the current record. (If you don’t select this option, Go to Related Record makes the first record in the table’s unsorted order the current record.)

          A sample script to take you to a SINGLE record in a portal that will always work as expected:

          Set Variable [ $id ; portalTable::primaryKey ]

          Enter Find Mode [ no pause ]

          Go To Layout [ portalTableLayout ]

          Set Field [ portalTable::primaryKey ; "==" & $id ]

          Perform Find

          So instead of using GTRR to go to a found set of related records (the entire portal contents), you are going to that portal table's layout and performing an exact find for the single record you want to go to.


          In a one to many relationship, if you use GTRR from the one side, you will go to "many" records. If you use GTRR from the "many" side, then you will just go to ONE record via the relationship.

          2 of 2 people found this helpful
          • 2. Re: Go To Related Record not taking me to the correct record

            Hi Mike,


            Thanks, that works perfectly! And it does make total 100% sense. I'm astounded that this hadn't occurred to me before... I've been using Filemaker for 8 years now and never ever come across this problem !


            Maybe it's because I'm used to searching within the record itself rather than linking into it via a portal (or browsing to a different record if I've linked):- different eyes notice different things.




            • 3. Re: Go To Related Record not taking me to the correct record



              Not to take anything away from Mike's approach, which does work (as you found out), but there are other ways, as well.


              If this is something that you will be doing a lot and warrants a little extra schema, you can create another relationship with a new global and a new TO. Have the global be in the table that the layout is based on and the relationship go to the primary key of the child record. Then if you want to go to ONE record, set the parent global to the primary key of the record you want and then do your GTRR to that new TO.


              For instance if you have a button on the portal row, call this script with the key of that record as your parameter:


              Set Field [ currentTableOccurrence::g_childRecordID ; Get ( ScriptParameter ) ]

              If [ not IsEmpty ( newChildTableOccurrence::ID ) ]   // Only go if we know a record exists

                        Go To Related Record [

                                       Show only related records ;

                                       From table "newChildTableOccurrence" ;

                                       Using layout: "Child Table Layout"


              End If

              Exit Script [ ]


              Incidentally, since keys can be multi-line, you can go to all the records in the portal by changing the first line of the script to:


              Set Field [ currentTableOccurrence::g_childRecordID ; List ( portalTable::primaryKey ) ]


              I like this approach because I can pick and choose which child records to go to before even changing layouts. Throw in a little ExecuteSQL to gather a complicated set of keys in the child table and this technique becomes even more handy.


              And, as with all uses of the GTRR, don't forget to check that there are records there before you invoke such a context-changing script step. I also usually add a little error-checking when I get there, especially if I am about to delete anything.



              1 of 1 people found this helpful
              • 4. Re: Go To Related Record not taking me to the correct record

                While you do get a found set of records, the GTRR should make the portal record where you clicked the button the current record. In a form view layout, that's often all that you need. If this is not happening, something else is interfering with the portal focus or the results of your GTRR--typically script triggers are the culprit.


                If I need to isolate the portal row that I clicked in a found set of one record, I do it this way:


                Go To Related Records [ //specify the portal table occurrence to get found set of records shown in portal

                Find Matching records [Specify the primary key of the portal table here ; Replace ]


                Two steps, no added occurrences.