6 Replies Latest reply on Oct 22, 2010 1:20 PM by MatthewTschippert

    Getting Record from Different File



      Getting Record from Different File


      I am trying to create a script/custom function that gets a container field from a different file and inserts it onto the current file.

      The outline would be something like

      Select container field using drop down list
      ->ScriptTrigger (OnObjectEnter)
      --> Copies container contents from individual record
      --->Pastes container contents in designated field.

      The purpose of this is to streamline the process of searching through an entirely different file for an image/panel that would then have to be copied and pasted and realigned. I do NOT want to just merge the two files because then the filemaker file would become rather large. Currently, there is a file with the collection of panels and it is already close to 40mbs.

      The point on this script that I am stuck on is just selecting the data::table from the second file. I figured I could somehow access this second file, perform a find in Name field using the name of the drop down list (Value list currently set up is using the name field from the second file), and then import or copy/paste container field from the found record.

      Could I get some tips on the accessing second file?


        • 1. Re: Getting Record from Different File

          Filemaker doesn't care whether a table is in one file or another. You can accomplish what you need by relating the table from file 2 to the relevant table in file 1. Then simply place the container field containing the image on a layout from file 1. Each file will need to be listed as an External Data Source in the other. You can read up on this in Help.


          • 2. Re: Getting Record from Different File

            Ok thanks! I will look into it. I guess the biggest problem was that I did not know what I was exactly looking for (in terms of solutions) in help/developer reference/google.

            • 3. Re: Getting Record from Different File

              Here's one simple way.

              Let's assume your image file has three fields: ImageID (auto-entered serial number), Image ( container) , ImageName (text)

              In your main file, Open manage | Database | Relationships and click the button on the bottom far left just above the Print button to create a new relationship.

              This brings up the Specify Table dialog. Select Add Filemaker Data Source from the table drop down.

              In the Open File dialog that pops up, find and open your image file. Since there's only one table in this file, it's already selected for you, click Ok to dismiss the Specify Table dialog.

              Now you have a table occurrence in your Relationship graph for your external image file and you can treat it like any other table in your file.

              Define a field in the table of layout where you want to look up an image called ImageID. Let's call this table "Main".

              Now define a relationship between the two tables:

              Main::ImageID = ImageFile::ImageID

              Place Main::ImageID on your layout and format it with a value list that has the ImageID numbers from ImageFile::ImageID in column 1 and the ImageFile::ImageName field in column 2.

              Now place the Image container field from ImageFile on your layout and when you select an Image in Main::ImageID, the corresponding image from your image file will appear in the image field.

              This is a basic set up. There are other ways available that make it easier to work with long value lists in order to make it easier to find the desired value list by name. You can even set up a portal to the Image file that displays thumbnails of the images along with their names where you can click a listed image to add it to your current record in Main.

              • 4. Re: Getting Record from Different File

                Thank you Phil. That is about where I got as I looked at your post. I double-checked everything and sofar it appears to be working. However, I am looking for a way to break it and seeing any flaws that may exist. (Currently, the only flaw is that the image gets stretched since it is a container field.) Regardless, I guess I am one step further than I was previously on my goal of streamlining the whole form creation process I do for work.

                Thanks again!

                Matthew Tschippert.

                • 5. Re: Getting Record from Different File

                  Enter layout mode and select the container field.

                  Then use the inspector to change the graphic format options for your container field. Select the "Maintain original proportions" option and the images will not be distorted.