6 Replies Latest reply on Oct 29, 2009 3:04 PM by mrvodka

    Script

    una

      Title

      Script

      Post

      Hi

       

      I have a table that is related to a number of other tables via a Client ID field. I am trying to create a script that will open a new record in any of the other tables that will automicically insert the value for Client ID. I was going to have a button on the original table that will allow me to do this.

       

      Any help would be great.

       

      Una.

        • 1. Re: Script
          mrvodka
            

          Set Variable [ $clientID; Client::ClientID ]

          Go to Layout [ "Table2 Layout" ]

          New Record/Request

          Set Field [ Table2::fkClientID; $clientID ]

          Go to Layout [ "Orig" ]

           

           

          Another option could be to turn on allow creation of record on the child side of all your relationship. Then you can use a portal to enter in new records.

           

           

           


          Edit: Adding step missed

           

           

          • 2. Re: Script
            una
              

            Hi there,

             

            Thanks for that but I can't really figure out how it works. My original table is called Personal Information and its linked to a 4 other tables (General Information, Support Visits etc) via Client ID. The way I have done it is that I have linked CLient ID from Personal Information to CLient ID in each of the other tables individually.

             

            From what you have advised, I managed to get most of the script but I can't seem to get the 'set field' part.

             

            From the way I have related the tables, can I create a new record in each of the tables from any of the other tables and have the client ID entered automatically in the new record? I have also programmed a each new record to have a serial number field - i.e., Suppvisits ID.

             

            If I try the other method, i.e., via a portal in Personal Information, how do I create a new record in another table this way?

             

            I know this all seems a bit convoluted but I'm trying to make it look as user friendly as possible..

             

            Many thanks for any help you can provide

             

            Una

            • 3. Re: Script
              mrvodka
                

              The script would be something like the following:

               

               

              Set Variable [ $clientID; Personal Information::Client ID ]

              Go tot Layout [ "Support Visits" ]

              New Record/Request

              Set Field [ Support Visits::Client ID; $clientID ]

              Go to Layout [ "Orig" ]

               

               

              However, perhaps you should state why you need to create empty child records in 4 other tables?

               

               

               

              Edit: Adding step missed

               

              • 4. Re: Script
                philmodjunk
                  

                "If I try the other method, i.e., via a portal in Personal Information, how do I create a new record in another table this way?"

                If "Allow creation of records..." is enabled for the portal table occurrence, the portal will show a blank row immediately below any existing portal records. Simply enter data into the fields in this row and filemaker will automatically enter the matching ID value so that the relationship linking the records is corrrectly set up for you.

                 

                Mr. Vodka, isn't your script example missing a step?

                 

                Set Variable [ $clientID; Client::ClientID ]

                Go to Layout [ "Table2 Layout" ]

                New Record/Request

                Set Field [ Table2::fkClientID; $clientID ]

                Go to Layout [ "Orig" ]

                • 5. Re: Script
                  una
                    

                  Hi there,

                   

                  THanks a million for this.  I have managed to get the script working.

                   

                  Una.

                  • 6. Re: Script
                    mrvodka
                       Indeed. Thanks for the catch.