4 Replies Latest reply on Jan 30, 2012 5:21 PM by philmodjunk

    How To show only related record in List View REVISITED

    PolyPaparas

      Title

      How To show only related record in List View REVISITED

      Post

      Hi,

      I know this has been addressed before, but it has not worked for me...

      I have built a patient database for my patients.

      For simplicity's sake lets say we have two tables, PATIENTS, and VISITS, related via Pt_ID.

      I want to have a list view of all the Visits related to a single patient.

      I tried doing a script with the go to related record command, but this onlly works for the first time the layout is entered.

      If I change the patient record to another patient, the related records from the visits table are not updated.

      I tried using a onlayoutenter script with the gotorelatedrecord script step but this did not work.

      I then tried using the perform find command but this did not work either, as it then got stuck to the found set and could not change patient records...

      Any ideas would be greately appreciated.

        • 1. Re: How To show only related record in List View REVISITED
          philmodjunk

          Both a script that performs a find and go to related records can work here. The devil, however, is in the details.

          If you place a button on the patients layout that uses Go to Related records to pull up visits records, it should bring up just the visits for that patient each time you click the button unless there are no visits records for that patient--in which case nothing happens and you are still left on the patients layout unless you add checks for this situation and pop up a message telling the user that there are no visits records for that patient.

          In similar manner, a script that copies Patients::pt_ID into a variable, changes to the visits layout, and uses the value in the variable to find Visits records with the same ID.

          It's even possible to add a  global field with a drop down of  patients on the visits layout with a script trigger that performs such a find so that you can pull up different sets of visits records without having to return to the patients layout.

          A final variation:

          Put a portal to visits on Patients, then add a button in the portal row with go to related records. This can be used, not only to find the visits recors for that  patient, but the specific record clicked in the portal row becomes the current record on the visits layout.

          • 2. Re: How To show only related record in List View REVISITED
            PolyPaparas

            I have been using the portal solution for several years, but I does not work well on the ipad, so I want to change to a list view

            I have tried most of the options you describe, maybe I am doing something wrong...

            First option

            I am looking at the patients record and I click on a button calling a script to go to this particular patient's visits in list view...

            the whole idea is the layout is pulling records from the patients table, and then instead of having a portal displaying the related records from the visits table, use a list view to do this.

            If I try to use the Go To related record script command, FM does not allow me to pull the related records from the Visits table, and the use a layout that pulls records from a different table!

            i.e.

            Go to Related Record [show only related records; from table: "visits"; using layout: <Visits List view>]

            all the layouts that pull records from the table "patients" are not available as an option to pick...

            If I make the layout pull records from the "Visits" table, then I cannot navigate to different patients records...

            I tried using a

            Go To Layout["Visits List View" (patients)]

            script step, and then

             Go to Related Record [show only related records; from table: "visits"; using layout: <current layout>]

            this brings up the correct related records, but I get the following error

            "this operation could not be completed because this layout cannot display the result"

            And when I navigate to a different patient record it does not update the shown related records

            I tried using a perform find approach with the following script

            Set variable [$pt_id; Value:Patients::pt_id]

            Go to layout ["Visits List View" (Patients)]

            Enter Find Mode []

            Set field [Visits::pt_id; $pt_id]

            Set error capture [on]

            perform find []

            but this brings up nothing.

            I suspect this is due to the fact that the layout is pulling records from "Patients"...

            This is so complicated!!!

             

             

             

             

            • 3. Re: How To show only related record in List View REVISITED
              PolyPaparas

              continued...

              I changed the layout to pull records from the "Visits" table.

              This time the visits show up correctly but then I cannot navigate to a different patient record.

              I have four buttons on the header, each executing a "Go to record/request/page first/previous/next/last" script step. if I change the layout to ull records from the Visits table, then these buttons only navigate within the Visits table...

              is it possible to write a script to navigate the "Patients" records from within the "Visits" layout?

              • 4. Re: How To show only related record in List View REVISITED
                philmodjunk

                Yes, Make your go to record scripts work like this example that pulls up visits records for the next record on your patients layout:

                Freeze window
                Go to layout [patients]
                Go to record/request/page [next]
                Go to Related records [//specify criteria to return to visits layout with visits records]

                You can include tests such as Get ( RecordNumber ) = 1 and Get (RecordNumber ) = Get ( FOundCount) to identify when you have reached the first and last patient record on the patients layout.

                One of the key secrets to successful scripting in FileMaker is to use go to layout to control what record, found set and sort order is "current" for the steps immediately after the go to layout step.