7 Replies Latest reply on May 11, 2010 4:11 PM by cisco1115

    Script to open a record in another database

    Algo

      Title

      Script to open a record in another database

      Post

      I am trying to open a record in another database, based on the value of a field in the first database.  (groups/agents if you saw an earlier post about importing).

       

      Open File("Agent Database.fp7")

      Perform Find("Agent Database::agentID": =)

      Select Window("Agent Database")

       

      It opens the Agent Database but does not perform the find.  To even get the Agent Database to show up in the find options I had to add it as a table in the relationships of the Group Database.  I was hoping it would prompt the user for a password when it started to perform the find. 

        • 1. Re: Script to open a record in another database
          philmodjunk
            

          Put the find script in the other file and use Perform find in your first file to specify the script in the second file.

           

          With regards to accounts/passwords. If you use a script to directly or indirectly open a second file, Filemaker first attempts to open the file with the same account name and password used to open the original file. If there is a matching account name and password, the file will open without asking for a password. If there is no matching account name/password, the password dialog should appear.

          • 2. Re: Script to open a record in another database
            Algo
              

            How am I supposed to pass the agentID from the script in the first database to the script in the second database?

             

            Nevermind I just found it:  Get(ScriptParameter) 

            • 3. Re: Script to open a record in another database
              cisco1115

              I am trying to acomplish the same thing on Filemaker 11, can you show an example of how you got your script to work?

               

              So far I have a button that performs the following script:

               

              Open File["Computers"]

              Perform Find[Restore] - in the requests I have: Action= Find Records, Criteria= Computer Library::User [ = ]

              Select Window [Name: "Computer Library"]

               

              Under "Optional script parameter" i have:

              Personnel Records::User

               

              Thanks in advance

              • 4. Re: Script to open a record in another database
                philmodjunk

                In layout mode, double click the button, and click specify...

                 

                At the bottom of the dialog is a box for entering the value(s) you want to pass to your script as a parameter.

                 

                You can enter a literal value or click the edit button and specify a calculation such as the name of a field that contains the value.

                 

                In your script, you do this:

                 

                Go To layout [//Specify a layout based on the table you want to search]

                Enter Find Mode []  //no specified criteria, no pause

                Set Field [YourTable::YourField ; Get ( ScriptParameter ) ]

                Set Error Capture [on]

                Perform Find []

                • 5. Re: Script to open a record in another database
                  cisco1115

                  Hello,

                   

                  I tried to replicate the settings but it hasn't worked for me.

                   

                  here are my settings:

                  Button->Control->Perform Script 

                  current script options: pause.

                   

                  Original script parameter: Personnel Records::Name First Last

                   

                  The script specified does this:

                   

                  Open File ["Computers"]

                  Go to Layout[Computer Library::User]

                  Enter Find Mode[]

                  Set Field[Computer Library::User[ Get(Script Parameter) ] ]

                  Set Error Capture[On]

                  Perform Find[]

                   

                  • 6. Re: Script to open a record in another database
                    philmodjunk

                    Your script will search a table in your current file. If you want to search records in an external file, the script has to be in the second file.

                    Open your second file and put the steps starting with Go To Layout in a script in this second file.

                     

                    When you add the button or double click it while in layout mode to bring up the button setup dialog,

                     

                    You select perform script and click Specify... to bring up the specify dialog. Then you select the second file from the drop down at the top of this dialog. If your second file isn't listed in the drop down, select Add Filemaker Data Source and use the open file dialog that appears to find and open the second file. Now you'll get a list of scripts from this second file and you select your script from this list.

                     

                    The script you've posted can be made to work, but you have to first create a table occurrence in your current file that references the table in your second file and then create a layout based on that table occurrence.

                    • 7. Re: Script to open a record in another database
                      cisco1115

                      Got it to work, Thanks for all your help!