6 Replies Latest reply on Apr 27, 2017 5:48 AM by everyman

    Performing a find in another FM File

    gedkins

      Hi,

       

      I have a Master Item FM file that is a series of items we fabricate or buy. I have Purchase Requisition FM file that users create records in to buy things found in the Item Master file.  I am trying to allow the users to update Item Master records (not create new ones)  when working in the PR file. I tried to create a script in the PR file that will grab a value in the PR file (a part number) and then open the MI file and perform a find on that value. When I use the Open File script line it opens the file, but apparently the next steps in the script (Show All Records and Enter Find mode) actually executes against the PR file and not the newly opened MI file.  How do I transfer execution of a script running in one file to another file?  I suspect its fairly simple, but perhaps it is not.

        • 1. Re: Performing a find in another FM File
          coherentkris

          You should learn how to use external data sources.

          It allows you to share tables between files so you dont have to go through all those steps to get two files to work together.

          FileMaker Pro 15 Help

           

          Another possibility is to merge the two files into one.

           

          finds are context specific ( what is the active window and what Table Occurence is the layout in the window bound to when find is performed?)

          1 of 1 people found this helpful
          • 2. Re: Performing a find in another FM File
            philmodjunk

            With that external data source, you can add an occurrence of that table in your PR file and then a layout in your PR file based on it. Your script could then go to that layout to find records, but there are other ways to access data in that table that do not use a find that you might also consider.

            • 3. Re: Performing a find in another FM File
              gedkins

              Maybe I am missing something. I have already created an external data source via the Manage function for the IM database. This allows me to type in a part number in the PR file and FM then grabs all the associated data to the part number (description, cost, etc.) and populate the portal in the PR file. My question arises from the fact that on occasion the IM records are lacking all the related data and I wanted to give the users a chance to update those records as they discover the missing data.

               

              NT DB.png

              • 4. Re: Performing a find in another FM File
                everyman

                Write the search script (Enter Find Mode, etc.) in the Master Item file.  Specify to the calling Perform Script step (in the PR file) the target file as well as which script.  (At the top of the Perform Script dialog is a menu to select the target file.)

                 

                Use script parameters and the Exit Script step to pass information to the target script and back to the caller.

                 

                For example, the caller might want to search for part number 5678 in the master file.  The Perform Script step might be:

                 

                Perform Script [ "Search for Part" from file: "Master Item" ; Parameter: 5678 ]

                 

                and the Search for Part script would include:

                 

                Set Variable [ $partNumber ; Get (ScriptParameter) ]

                 

                Search for $partNumber and then do something with the results -- update the matching record, call another script, return the number in inventory to the caller, etc.

                • 5. Re: Performing a find in another FM File
                  rgordon

                  To answer your original question. A find script needs to be in the master file. From the Pr file you call the find script in the master file. Use a script parameter to pass the find value from the PR file to the master file. In the master file use Get(scriptparameter) to retrieve the find value. Btw, you also do not need to do a show all before doing a find.  Also as mentioned previously, there probably are better ways to accomplish what you want.

                  • 6. Re: Performing a find in another FM File
                    everyman

                    Create a second table occurrence of the relevant IM table and use a global field (populated with the part number) as the left side of the relationship.

                     

                    There are other ways to accomplish the same thing: switch to a layout with the IM table and search it is one.