6 Replies Latest reply on Jul 22, 2010 3:30 PM by philmodjunk

    Copy fields to new file problem (as in new job from client file)

    yandg

      Title

      Copy fields to new file problem (as in new job from client file)

      Your post

      I am stuck on what i thought i had already acheived. Where have i gone wrong?

      FMP11

      Have 2 files - EG;              Client file    and    Service File.

      I have a script fired from a 'New Job' Button in the client file.

      I need to copy data from 5 fields in the client file to a new record in the service file, populate the 5 fields in the service file and be ready to enter further info as required for the Job.

      The script stores the 5 fields into 5 variables then opens 'Service' file  and new record request.

      Then fills the appropriate 5 fields from the 5 variables.

      This seems to work but not correctly a new record seems to appear in the client file although the service file opens up with the data showing correctly.    The record cant be completed as it tells me this record is already open in another window.

      I can see i have to set the cust_id (which is the link) first and then look at the related record but if i do this i can only use the 'New Job' button once as each subsequnet  time it looks at the original new record and doesnt add a new one.

      I'm sure i did this originaly but something has gone wrong somewhere from trying in FM9 and now in FM11

      Any pointers appreciated.

       

      Mike

        • 1. Re: Copy fields to new file problem (as in new job from client file)
          philmodjunk

          This sounds like a question that should be asked in Using Filemaker rather than Using Filemaker Server--though the new forum software makes it all too easy to lose track of which forum you're in at any given moment...

          Please post your script. A fairly easy way to do this is to print your script to a PDF and then use Acrobat Reader's text tool to copy and paste the script text to the forum. If you have filemaker advanced, you can copy the script from a database design report.

          • 2. Re: Copy fields to new file problem (as in new job from client file)
            yandg

             Hi, yeah your right didnt realize i was in the server forum still!

            Sample script as below, i have tried this again just now and it has seemed to work ok. Although yesterday i couldnt update the new service record as it said it was already being updated. Would me adding the various files in the 'External data source' menu make any difference?

            • Set Variable [ $custid; Value:clients::cust id ]
            • Set Variable [ $surname; Value:clients::surname ]
            • Set Variable [ $address; Value:clients::address ]
            • Set Variable [ $street; Value:clients::street ]
            • Set Variable [ $town; Value:clients::town ]
            • Set Variable [ $country; Value:clients::county ]
            • Set Variable [ $postcode; Value:clients::post code ]
            • Set Variable [ $telno; Value:clients::tel no ]
            • Set Variable [ $mobile; Value:clients::mobile no ]
            • Open File [ “service” ]
            • Set Field [ service::cust id; $custid ]
            • Set Field [ service::Customer Surname; $surname ]
            • Set Field [ service::Address; $address ]
            • Set Field [ service::Road_street name; $street ]
            • Set Field [ service::Town; $town ]
            • Set Field [ service::County; $county ]
            • Commit Records/Requests
            • Go to Related Record [ From table: “service”; External; Using layout: <Current Layout> ]

            I started with this option as we might want to fill out a service record by manually entering this information instead of starting from the client file. Thought i could then also add a button(Script) that does the opposite of the above and creates a new client record from the one just created manually in the service file. ?

            Many thanks for all the help

             

            Regards Mike

             

            • 3. Re: Copy fields to new file problem (as in new job from client file)
              yandg

              Now thinking about this set up again.....  

              am i better to have the 'client' and the 'service' files defined as tables in the same file rather than 2 seperate files ????

              As i have with the 'sales' and 'stock' records.

              Comments anyone ?

               

              • 4. Re: Copy fields to new file problem (as in new job from client file)
                philmodjunk

                Filemaker can treat the tables of external files just as though they are all files in the same file. As new user, it's probably easier to have them all in one file, you can use Import Records with the new table option to pull a table and it's data into a different file.

                The external file, is the issue here. As currently written, if you keep the separate files, you'd need to split your script into two parts. Part one runs in the first file and then uses Perform script to call the script in the second file, passing the data in a parameter list to the second script.

                However, there's a more basic issue here. You should not be copying this data at all. Instead you should only enter this data in the client table and then link it via a relationship in Manage | Database | Relationships to the service table by client ID. With the relationship established, you can simply place the fields from Clients on your service layout and the data will appear when you select a client's id number. New clients should be recorded in the client table before you start a project record for them.

                This is just a general outline, you'll have to implement a number of details to make it work. You may need to invest in a training tutorial or a book on filemaker. You are also welcome to keep asking questions here at the forum.

                • 5. Re: Copy fields to new file problem (as in new job from client file)
                  yandg

                  Many thanks yet again,

                  i have set up as you suggest and let the details in service 'source' from the client file and not store details twice. I did this originally but for some reason didnt pursue this option. I think i came across a problem at the time.

                  The other set back i have with the seperate file set up as opposed to tables in the same file is that i cant always find and switch lto different layouts in different tables as they arent always listed as available.  Think this again is down  to me not setting up correctly the linked files/tables.

                  Have dissected one of the sample files and can see how to perform the script call from the script in the original file, this would works ok aswell,

                  Have a book on the way so should start to drop into place soon

                  Many thanks for your input once again

                   

                  Mike

                  • 6. Re: Copy fields to new file problem (as in new job from client file)
                    philmodjunk

                    The layout drop down in the status area will only list layouts in the current file. To get to specific layouts in another file, you'd need to write a script in that other file that selects the correct script and then call that script from the first file...

                    Which illustrates another reason for putting all your tables in a single file...