11 Replies Latest reply on Aug 23, 2012 11:05 PM by philmodjunk

    How to format field as a button that uses Open URL to open a file

    Elise

      Title

      How to format field as a button that uses Open URL to open a file

      Post

       

       file path link imported from Excel into FM text field no longer works as a link to retrieve file
      Post:

       I am not script saavy and am seeking a step by step resource on how to preserve the hyperlink ability of a filepath link imported into FM from Excel.  I am using Windows7 OS. 

      Anyone know of a step by step reference for making a text or container field a hyperlink field so this imported link can work within FM Pro 12?

        • 1. Re: How to format field as a button that uses Open URL to open a file
          davidanders

          Text in layout formatted as hyperlink with script attached.

          http://fmlayoutmode.com/wp/?p=1

           

          http://help.filemaker.com/app/answers/detail/a_id/2982/~/how-to-go-to-a-url-from-filemaker-pro
          You can use the Open URL Script step in ScriptMaker to open URL's.

          About the Open URL script step:
          Format
          Open URL [No dialog; <URL>]
          Options
           

          • Perform without dialog prevents the "Open URL" Options dialog box from displaying when the script step executes.
          • Click Specify to display the "Open URL" Options dialog box, where you can type the URL directly in the text entry area or click Specify to create your URL from a calculation.
             

          Web compatibility
          This script step is web-compatible.

          Description
          Windows:

          Allows the user to open a URL. Open URL supports http, ftp, file, and mailto URL types. For example, if the URL starts with http, FileMaker Pro opens the user's web browser and processes the URL.
          Note 
          FileMaker Pro uses the preferences stored in the Windows system file URL.DLL to determine the application to handle the URL. The URL is then passed to ShellExecute for execution.

          Mac OS:
          If the user has configured the Internet system preferences, this script step allows the user to open a URL. Open URL supports http, ftp, file, and mailto URL types, using the applications specified in either the control panel or system preferences. For example, if the URL starts with http, FileMaker Pro opens the user's web browser and processes the URL.

          Examples 

          1. The following example is a script that can be assigned to a button which opens the user's web browser and displays the URL specified in a field within the file:

          Open URL [No dialog; MyFile::MyField]

          where `MyFile' is the FileMaker Pro database name and 'MyField' is the field that stores different URL's to navigate to.

          2. The following example opens the user's web browser and displays the FileMaker, Inc. home page (the URL specified when the Open URL script step was defined):

          Open URL [No dialog; "http://www.filemaker.com/"]

          3. The following example opens Windows Notepad and opens the file My_File.txt on the root level of the user's hard disk:

          Open URL [No dialog; "file://c:/My_File.txt"]

          4. The following example launches the preferred email application, opens a new email message, and uses the value in the Email Address field to address the message. The email address must start with mailto:.

          Open URL [No dialog; "mailto:email address"]

          5. You can also use the Open URL script step to open a shared FileMaker Pro file running on another system, as follows:

          Open URL [No dialog; "fmp7://system:user@testlab-mac/testdb"]

          where `system' is the FileMaker Pro account name, `user' is the password, `testlab-mac' is a DNS entry for the machine where the file resides (you can also use an IP address for this parameter), and `testdb' is the FileMaker Pro filename.

          Important  Account name and password information entered in an Open URL script step is visible to users with script editing access privileges, and is therefore not secure.

          • 2. Re: How to format field as a button that uses Open URL to open a file
            philmodjunk
            1. Open Manage Scripts
            2. Click new
            3. give your script a name.
            4. Double click Open Url on the list of steps down the left hand side of the script editor to add this step to your script.
            5. Click the specify button.
            6. click the Specify button in the dialog that pops up when you click the first specify button.
            7. Find your field in the list of fields at the top of the specify calculation dialog and double click it to add it to this calculation.
            8. Click OK in both dialogs to close them and get back to the script editor.
            9. You should see: Open URL [Yourtable::yourField], but with your table and field names.
            10. Click OK to close the script editor, saving your new script.
            11. Return to your layout.
            12. Enter layout mode
            13. Click your field. Select button Setup... from the format menu.
            14. Select the perform script option.
            15. Click the specify button and select your script as the script to be performed when the field is clicked.

            Please note: this may not work without first using a calculation to modify the data in your imported text. This is why I asked you to post an example of what you are importing as a hyperlink so that I could suggest such a calculation if one is needed. You can use the Post A Answer box here to post that info as part of these same discussion thread.

            • 3. Re: How to format field as a button that uses Open URL to open a file
              Elise

              PhilModJunk,

              Thanks for the steps you outlined.  Very helpful. 

              Here is a sample file path in the FM Pro 12 text field that I would like to make linkable.  Do I need to add anything in calculations to make it work correctly? 

              Y:\tests\data.docx

              I followed the steps you outlined and for some reason the link opens my pictures directory and not the file the link corresponds to.

              • 4. Re: How to format field as a button that uses Open URL to open a file
                philmodjunk

                That should have opened the file, but I should have had you also click the "no dialog" button to get:

                Open URL [No dialog ; Yourtable::yourField]

                But make sure that you do not have:

                Open URL ["YourTable::YourField"]

                • 5. Re: How to format field as a button that uses Open URL to open a file
                  Elise

                   This works very well.... thanks again!

                  • 6. Re: How to format field as a button that uses Open URL to open a file
                    AnnetteVillarreal

                    PhilModJunk,

                    I have followed the steps for this exactly. I have successfully created a button from the Form View and List View. The button doesn't appear in the Table View though. How can I make that happen?

                    Thanks

                    • 7. Re: How to format field as a button that uses Open URL to open a file
                      philmodjunk

                      Buttons are not visible in the body of the layout when you are in table view. Use list view instead. You can arrange fields in a row and reduce the size of the body layout part to just the minimum needed to display a row of fields and your buttons. In browse mode, this will look and function very similar to your table view.

                      You can put buttons in the header of a table view when you use layout setup and select the options for table view that makes the header visible, but I don't imagine that a button in the header will work for you.

                      • 8. Re: How to format field as a button that uses Open URL to open a file
                        AnnetteVillarreal

                        Okay. In table view, what is the easiest way to create a hyperlink with text to display? I can add a hyperlink, but it comes out as simply text.

                        • 9. Re: How to format field as a button that uses Open URL to open a file
                          philmodjunk

                          I suggest that you not use table view. Table view is best suited as a "debugging overview" of your data for diagnosing issues with your data or your database design. It's not the most user friendly view for general users to use when they access your database.

                          If you must use table view, add the URL field to your layout while in layout mode. It doesn't matter where you put it as long as it is in the layout body somewhere. Right click this field and add an OnObjectEnter trigger to perform the Open URL script.

                          • 10. Re: How to format field as a button that uses Open URL to open a file
                            AnnetteVillarreal

                            Can you please provide  step by step instructions for the table view option.

                            • 11. Re: How to format field as a button that uses Open URL to open a file
                              philmodjunk

                              I thought that I had. Wink

                              Enter layout mode.

                              Use the field tool from the tool bar to drag and drop a field onto your layout. Drop it anywhere.

                              Specify fields pops up. Select the the field you want from this dialog.

                              Right Click the field (or the Mac equivalent) and select Script Triggers from this pop up menu.

                              Click OnObjectEnter check box.

                              Click Specify and select the script you want performed when you click or tab into this field.

                              Return to browse mode and test.

                              You may need to click the modify button to place this field where you want it in your table view.