13 Replies Latest reply on Mar 2, 2012 12:25 PM by disabled_JackRodgers

    Opening a Filemaker FIle with Open URL script step

    carlo.m

      Title

      Opening a Filemaker FIle with Open URL script step

      Post

      I have a script with just one step in it:

      Open URL [No dialog; "fmp7://~/host"]

      where host.fp7 is the file I'm trying to get to open. Right now I have that file on my desktop, where I also have the file I'm trying to open it with...

      I get this error "The file “host” could not be opened.  Either the host is not available, or the file is not available on that host."

      I can't use open file because this is to open files that will be developed after the launch of the version I'm working on now, and using Open URL I don't have to update the client version each time I need it to open another file. I will just have a hosted database with a table that has files on it, and on clicking it set the path to use in the URL with a variable... But I can't even get it to work without variables right now...

       

      WHAT AM I DOING WRONG??? What am I missing? Is there some requirement or option to set for it to work?

        • 1. Re: Opening a Filemaker FIle with Open URL script step
          philmodjunk

          Have you tried using Open File from a runtime? I thought the binding process included code that modified file name references to work with the .usr copies produced by this process.

          For Open URL, I'd use:

          Open URL [No dialog ; "file:" & Get (DesktopPath) & "Host.fp7"]

          • 2. Re: Opening a Filemaker FIle with Open URL script step
            carlo.m

            Do USR's work on iOS?

            I'm doing this for an iClient that I'm making for one of my solutions.

            • 3. Re: Opening a Filemaker FIle with Open URL script step
              carlo.m

              I transfered my test file to my iPhone.

               

              I got it to work there, but not on my mac.

              How can that be?

              • 4. Re: Opening a Filemaker FIle with Open URL script step
                philmodjunk

                Open URL [No dialog ; "File:" & Get ( DesktopPath) & "MessageTemplateBuilder.fp7" ]

                Opened the file shown in quotes. It was located on my desktop. I'm using windows xp.

                You might try using Safari to open the file and note the URL produced in the URL box. If you take that URL and replace \ with /, it should work to open your file and you might see a difference in the URL that is needed for it to work on Mac.

                I still think you need to create a simple runtime and try using Open File to open the file instead of Open URL--which can be much slower to open the file.

                • 5. Re: Opening a Filemaker FIle with Open URL script step
                  carlo.m

                  @PhilModJunk: I was able to recreate your try with Windows Server 2008 {Open URL [No dialog ; "File:" & Get ( DesktopPath) & "MessageTemplateBuilder.fp7" ]}, which is what I have my solutions hosted on

                  As I previously said, I got {Open URL [No dialog; "fmp7://~/host"]} to work on iOS.

                  However, neither option is working for Mac (OS 10.5.8).

                  I also tried to mix up the to:

                  "fmp7:/"& Get ( DesktopPath) & "MessageTemplateBuilder.fp7"

                  and had no luck.

                  I was able to open a remote file on the mac using fmp7://hostip/filename

                  Following the same logic, I tried fmp7://localip/filename but it did not work...

                   

                  So I'm about 90% there. I just need a mac user who has been succesful at opening a local fmp file with open url.

                  • 6. Re: Opening a Filemaker FIle with Open URL script step
                    philmodjunk

                    I'm not sure this will work on Macs. I seem to remember someone else posting that it does not work on Mac systems. I'd love to be wrong about that. Which takes me back to this:

                    I still think you need to create a simple runtime and try using Open File to open the file instead of Open URL--which can be much slower to open the file.

                    Have you tried that? It's my understanding that this will work.

                    • 7. Re: Opening a Filemaker FIle with Open URL script step
                      carlo.m

                      It does work, however it doesn't work for my solution.

                      What I'm trying to do is create a client that can update itself.

                      After having the new file on the device, I need it to open and import records from the old client, so the new client has all the info previously entered by the user.

                      I got tangled up in my own problem. The reason I was using the Open URL script step is that Export Field Contents wasn't working with auto open on iOS. But it does work on both Mac and PC. So my problem is solved, Export Field Contents (new client FM file in a container field) Auto-Open when platform is Mac or PC, Open URL when it is iOS.

                      Then I will use import records with a variable pointing to the old client to import records. The name of the old client file will be passed through by the host file and linked by the device NICAddress.

                      After info is passed on succesfully to the new client. A global field called outdated version will have a 1 in it. Startup script will catch that and point user to newest version of the client.

                      • 8. Re: Opening a Filemaker FIle with Open URL script step
                        carlo.m

                        So... I'm still having trouble.

                         

                        When on Mac (haven't tried it on windows), if Export Field Contents is the last step in a script (or stack of scripts) and the auto-open is set, it does auto-open. But if there is a step after it, no matter which one I try, it does not auto open.

                        On iOS I have auto-open off, and immediately after it is the OPEN URL script, which does "pause" the current script to open the new file, and run its startup script which detects it is an updated client, imports data from the old client, when finished running that script the old client continues its script process which proceeds to lock the version, send a message saying update went good, closes the file and you are left in the new version.

                        With the Open File, is it just me that has to add another Data Source to be able to use it. Can it be done with a $variable?

                        Or has anyone out there had success opening a FM file using Open URL to open a local database?

                        • 9. Re: Opening a Filemaker FIle with Open URL script step
                          carlo.m

                          Found the answer for Mac and Windows:

                           

                          If [ // OS X
                          Abs(Get(SystemPlatform)) = 1 ]
                          Set Variable [ $FilePath; Value:// OS X file:///Users/<short name>/Desktop/<file name>
                          "file://" & Middle ( Get(DesktopPath) ; Position ( Get(DesktopPath) ; "/Users/" ; 1 ; 1 ) ; 99999 ) & Get ( ActiveFieldContents ) ]
                          Else
                          Set Variable [ $FilePath; Value:// Windows file:///C:/Documents and Settings/<account name>/Desktop/<file name>
                          "file://" & Get ( DesktopPath ) & Get ( ActiveFieldContents ) ]
                          End If
                          Open URL [ $FilePath ]
                          [ No dialog ]

                          Works perfect, thanks to those that helped. You triggered important ideas that lead to the solution.

                          • 10. Re: Opening a Filemaker FIle with Open URL script step

                            Perhaps you overlooked the Open File command which is far easier and point and click and you would have accomplished your task in 15 seconds.

                            • 11. Re: Opening a Filemaker FIle with Open URL script step
                              carlo.m

                              Hi Jack,

                              I don't know if you read the whole thread:

                              "With the Open File, is it just me that has to add another Data Source to be able to use it. Can it be done with a $variable?

                              Or has anyone out there had success opening a FM file using Open URL to open a local database?"

                               

                              I'm not trying to just open a file I have now, I'm paving the way for my solution to be able to open files that are not Filemaker Data Sources.

                              Also, using Open URL to open a Filemaker File, you can trigger a script with parameters from an unrelated file.

                              • 12. Re: Opening a Filemaker FIle with Open URL script step

                                Since I place all of my Filemaker Files in the same folder, it seems this is what Go does, I am using this in the open url dialog:

                                Open URL --> Substitute ( Get( FilePath) ; Get ( FileName ) & ".fp7" ; $_filename )

                                 

                                $_filename is the name of the file with .fp7. I set that in a variable so I can easily change it or get it from a button click.

                                 

                                This script gets the name of the active file containing the script, it's pathname and substitutes the file I want to open (which is in the same folder).

                                This is currently working on FM Pro, I say currently cause I often break stuff. It works in Windows not tested on OSX. Somebody test it and respond.

                                The aggravating part is that it does not work on IOS! Instead it opens Safari...  Gotta love the consistent way Go and Filemaker work together...  :)

                                • 13. Re: Opening a Filemaker FIle with Open URL script step

                                  Since I place all of my Filemaker Files in the same folder, it seems this is what Go does, I am using this in the open url dialog:

                                  Open URL --> Substitute ( Get( FilePath) ; Get ( FileName ) & ".fp7" ; $_filename )

                                   

                                  $_filename is the name of the file with .fp7. I set that in a variable so I can easily change it or get it from a button click.

                                   

                                  This script gets the name of the active file containing the script, it's pathname and substitutes the file I want to open (which is in the same folder).

                                  This is currently working on FM Pro, I say currently cause I often break stuff. It works in Windows not tested on OSX. Somebody test it and respond.

                                  The aggravating part is that it does not work on IOS! Instead it opens Safari...  Gotta love the consistent way Go and Filemaker work together...  :)