3 Replies Latest reply on Mar 14, 2013 1:50 PM by philmodjunk

    Opening a new record with information from another table

    PaulCane

      Title

      Opening a new record with information from another table

      Post

           The database I am in the process of making, contains customer information, and machines that they have installed at their premises I've made a dropdown menu that takes the user to a layout that has a portal showing all machines that the customer has, 

            

            I'd like to put an invisible button over the top of the portal records, so that when that record is "clicked", it will take you through to a service layout, and make a new record, and put the relevent information in to that layout.

           Structure-wise The customer key is called customerID

           machine is MachineID

           and Service is ServiceID

           Making the button isn't a problem its just the scrip ;)

            

           Any help will be much appreciated.

            

            

           Regards

            

           Steve

            

            

        • 1. Re: Opening a new record with information from another table
          philmodjunk

               Please confirm whether I have your relationships correct:

               Customers-----<Machines------<Service

               Customers::CustomerID = Machines::CustomerID
               Machines::MachineID = Service::MachineID

               If so, you may not need to add that invisible button. In layout mode, you can select all the fields in your portal row and use Button Setup... to make the group of fields into a button object.

               The button need only perform this script:

               Set Variable [ $MachineID ; value: Machines::MachineID
               Go To Layout ["Service" (Service) ]
               New Record/Request
               Set Field [Service::MachineID ; $MachineID]

               All other data from the Machine and Customer tables will be accessible to this new record via the relationships once you have entered the correct value in the MachineID field.

          • 2. Re: Opening a new record with information from another table
            PaulCane

                 Phil, your a diamond!!

                  

                 Looking at your script I can see I was sooo close to getting it right!

                  

                 I've tried to adapt the script to work on a dropdown box but not having much luck, Im using customer name in a dropdown box and want to go through to customer orders and open a new record from the name in the dropdown box and put the relevent customer information in the new record ie address etc

                  

                 Steve

            • 3. Re: Opening a new record with information from another table
              philmodjunk

                   Using the customer name might be a problem. You can easily have two or more customers with the same name--even if your customers are companies. A value selected from a drop down list can be used with either Go TO Related Records (IF you have the appropriate relationship that usees the drop down list field as a match field) or a scripted find. If you use a name for this, make sure to include code that can detect the fact that records with the same name exist and that then presents information to the users so that they can further refine their choice.

                   Here's a thread set up to share many examples of using a global field with a script to perform a find: Scripted Find Examples

                   And here's a demo file that uses an auto-complete enabled value list of names for selecting a record by name yet it establishes a link based on the ID number with code set up to handle cases with duplicate names:

                   FileMaker 12 users: https://dl.dropbox.com/u/78737945/SimpleNameLookupDemo.fmp12
                   Pre FileMaker 12 Users: https://dl.dropbox.com/u/78737945/SimpleNameLookupDemo.fp7