8 Replies Latest reply on Nov 17, 2009 11:00 AM by philmodjunk

    RE: COPY Multiple fields and Past Multiple Fields into new record as a script?

    cmaher

      Title

      RE: COPY Multiple fields and Past Multiple Fields into new record as a script?

      Post

      I am creating a database for an academic environment. I have one database for the main record and a secondary database for multiple contacts related ONLY to the main record. I want to "create" a new contact from the Main Record layout but I can't seem to get a script to copy multiple fields into the secondary database that would carry over the specific identifying information:

      First Name

      Last Name

      ID a

      ID b

       

      Can any one help me?

      Thanks!

        • 1. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
          ninja
            

          Howdy,

          This thread might help:

           

          Copying Data from the Previous Record...whats the best method?

           

          If you "File reference" your second Dbase from the first, you could simply add a "GoToLayout" step before the New REcord/Request step to go to a layout based on your second Dbase.  Trapping the data in the variables will let you "SetField" into the fields in the second Dbase.

           (and let you avoid using the clipboard with Cut/Paste)

           

          Is this what you're after?

          • 2. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
            philmodjunk
              

            Are you sure you need to copy any of these fields?

             

            With Filemaker Pro, if you have two related tables (the tables can reside in the same file or different files), you can simply place the fields from the related table on a layout based on the second table. This eliminates any need to copy the data and any changes made to the data in these fields are automatically visible in all the related records.

             

            Simply use the field tool to add the fields to your layout and select them from the related table. The relationship you define in Manage | Database | Relationships will control which record in the other table supplies the data to these fields. (If these are two separate files, you can still use Manage | Database to link them.)

            • 3. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
              cmaher
                

              I think I need to be able to copy and past multiple Fields - each main record represents an "unique" individual to hold general information and then each contact represents the various contact our office has with each "unique" individual. Our organization assigns two identifying numbers which I then use to define the relationship between the two databases (in addition to the First/Last Name of the individual) hoping to keep each Record and subsequent contact exclusive to the individual. To create a new contact I think I need to be able to copy First Name Field, Last Name Field, ID a Field, ID b field From Record into the related Contacted fields.

               

              I am new to Filemaker and not a computer programer - pretty much learning as I go..... any help would be greatly appreciated!

              Thanks!

              • 4. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
                cmaher
                  

                Assuming this was response that I was to look at - I was able to script the Set Vairable part but when it came to SET FIELD - I could only do the first part i.e., Set Field [myTable:text1] It would not let me add -  $myVar1 within as shown? 

                Set Variable [$myVar1; myTable::Text1]

                Set Variable [$myVar2; myTable::Text2]

                Set Variable [$myVar3; myTable::Text3] 

                New Record/Request

                Set Field [myTable:Text1; $myVar1] 

                Set Field [myTable:Text2; $myVar2] 

                Set Field [myTable:Text3; $myVar3]

                 

                Do I need to add Copy before hand and Paste script after?

                • 5. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
                  philmodjunk
                    

                  None of what you describe indicates a reason preventing simply referencing the fields in the original file. I would not use a person's name as part of the relationship. Names get entered incorrectly, people get married, people change their names for other reasons. In each case, a name based relationship will cause problems for you. Instead, define a serial number ID in your main table and use it as the key field linking to a matching number field in the second table.

                   

                  Specific to your set field question, click the lower specify button to enter the variable part of the step.

                   

                  If you must copy data from table to table, you can also specify a Lookup in the Auto-enter field options for each copied field--assuming you have a valid relationship linking the two fields.

                  • 6. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
                    ninja
                      

                    Howdy cmaher,

                     

                    Phil and I are giving two different solutions to your need.  They will both work.  Which you choose will depend on your database structure and task needs which we aren't privy to.

                     

                    Please Note: Phil's solution is a little more complex to build...but it is the better solution if it fits the end goal of your database.

                     

                    I am giving you another option if Phil's is inappropriate to your end use...though this is unlikely.

                    The option I proposed does not have copy and paste...it does not need copy and paste...copy and paste are a poor choice for moving data in a Dbase...SetVariable replaces the copy, SetField replaces the paste.

                     

                    If you can relate the data as Phil is suggesting, it will be to your benefit to do so.  If you need a quick patch to get the job done while you learn more about related tables...my method will buy you the learning time.

                    • 7. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
                      cmaher
                        

                      Thank you Phil and Ninja -

                       

                      Phil, point well taken about names as part of the relationship!

                       

                      I think the best would a combo of both and IF I am understanding this correctly - I should create a Filemaker generated Serial Number for each main record to be the Relationship between the Main Database and the Contact database.

                       

                       

                      Second I use Set Variable/Set Field for the creation of new contacts from the individuals Main Record based on that serial number so that maintains the intergrity of the Main Record/Individual contact. Yet any of us could still search out records/contacts via the organization's assigned IDS A or B?

                       

                      Set Variable [$serial1; mainrecord::serial number ID]

                      New Record/Request

                      Set Field [mainrecord::serial number ID; $serial] 

                       

                      Am I following both of you accurately?

                       

                      THANK YOU both! I have been going crazy over this for a bit

                      • 8. Re: RE: COPY Multiple fields and Past Multiple Fields into new record as a script?
                        philmodjunk
                          

                        Just keep in mind that with a valid relationship linking records between your two tables, all of the data transfer you are describing becomes completely unecessary. You can simply use filemaker's field tool to add fields from the first table to a layout based on the second table. The resulting fields can be setup to be editable or read only. This can actually be much easier to setup than creating a script to copy the data from one table to the other.