2 Replies Latest reply on Sep 26, 2013 10:03 AM by fysio2008

    Create record in related table



      Create record in related table


           I am new to Filemaker and have set up a simple database with two tables: "Patient" and "Journal"

           They are created in a one to many relationsship with the field "PatientId" in the patient table and "PatientIdFk" in the journal table.

           What I would like to create is a script so I can run that script via a button on a layout called "patient" and create a new journal record (and by the same time go to the layout I have called "journal")

           Each patient can have more journals.

           I know I can do that through a portal, but it is unfortunately not the best way for me, and I would like to do that via a click on a button outside the portal.

           Hope it all make sense.

           I have tried to create a script (See attachment) but I can´t seem to get it to work. It DOES create the new record and gives it a unique "JournalId" but it does not link it to the patient.

           Any help is appriciated. Thanks...



        • 1. Re: Create record in related table

               Your script is nearly correct. Both the Set Variable and Set Field steps lack the needed second parameter in order to work.

               Set Variable [$PatientID ; value: Patient::PatientID ]
               Go to Layout [
               New Record/Request
               Set field [Journal::PatientIDFK ; $PatientID ]

               When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

          • 2. Re: Create record in related table

                 That did it!

                 Thank you very much for helping me out smiley

                 It is very appriciated.