2 Replies Latest reply on Apr 15, 2011 2:04 AM by SibenMadze

    copy values from one file to another

    SibenMadze

      Title

      copy values from one file to another

      Post

      Hi, I have created a way to copy values from a field on a table in file A to a field in a related table in file B doesn't seem very elegant and I'm just wondering if there's another way to approach this that would be a little more concise.

      Basically I have created a script that's actually two scripts (one in each file) to copy/paste the values from the field in file A to the field in file B.

      The script works by using the "Copy" script step to copy the content from field A in the current layout  and then fires another script in file B to paste the values and  then goes back to the original layout.

      However, I am now in a position where I will need to copy the content  from many fields in a table in one file to many fields in a related  table in another file and with the way that I've figured out I will have  to create a seperate script for every field in each file.  Also, it uses the "Go to Related Record" script step to go to the other file which means it leaves the current layout.

      Is there a way to copy the content from multiple fields on one table  to a related table in another file without leaving the current layout,  and hopefully without creating a bunch of seperate scripts?

      Alternately, is there also a way to create a script that does the same thing but using two related tables in the same file?

      Thanks a ton!

      Cheers!

        • 1. Re: copy values from one file to another
          LaRetta_1

          I assume you are using vs. 7 or greater ...

          • There is no need to ever go to another file.  You can work with ANY .fp7 file right within your existing file.  Create an External Data Source to the other file so it appears in your graph (File > External Data Source).  Then create a layout to any of the tables from that file right within your working file and script going to those layouts instead of jumping between files.
          • Usually, the only time it is necessary to use another file is when you are separating UI from Data otherwise all tables can be within the same file.
          • Copy/paste is rarely used ... instead it is best to use Set Field[] because copy destroys the User clipboard contents and paste requires that the field be on the layout to work.  This can be a problem because 1) you may not need the field on the layout, 2) you may forget and remove the field from the layout and 3) it means you can't set related fields from a layout.
          • When you are attempting to set multiple fields from one table to another, it indicates that you are missing key concepts regarding relational theory.  Usually it means that you do not understand how to use Keys (primary and foreign keys) to relate your data so duplicating the data (redundancy) becomes unnecessary.

          We cannot properly answer your questions without knowing specifics.  We need to know the purpose and context of the tables/files involved, i.e. is it an Invoice file and and a LineItems file, set up as a one-to-many?  Is it Customers?  It is best if you can provide a link to your file for review but, at minimum, consider seriously the bullets above and then provide detailed description of what you want to accomplish and not how you think it should be accomplished.

          We can help you once we get you on the right track and once we have clear understanding on what you wish to do. :^)

          • 2. Re: copy values from one file to another
            SibenMadze

            Thanks, sorry about the lack of clarity in my explanation.. I realize how it would have been impossible to answer without the specifics of what I was trying to do.  As you guessed, I basically wasn't using some core relational database theories, but the advice you offered got me on the right track.  The solution I'm working on (in FMP 11) uses multiple files both to separate records from the UI and also to restrict access to certain records. 

            Thanks again!