5 Replies Latest reply on Jan 31, 2012 11:56 AM by philmodjunk

    Send Event -> Open Document (Mac)



      Send Event -> Open Document (Mac)


      Novice running FM Pro 7 on Mac OSX 10.68.

      Trying to setup a script to open a document, where the document name is the value of a field. The documents will always be located in the same directory as the FM file. 

      Not working:

      Send Event ["Preview"; "aevt"; "odoc"; GetField ("user_view::File Name")]

      The Mac app "Preview" comes to the front, but no document opens.

      When I specificy a file name in the script as follows, it works fine:

      Send Event ["Preview"; "aevt"; "odoc"; "file.pdf"]

      But, of course, I need the script to grab the file name from the current field "File Name".

      Can someone point me in the right direction?


        • 1. Re: Send Event -> Open Document (Mac)

          Send Event ["Preview"; "aevt"; "odoc"; user_view::File Name]

          • 2. Re: Send Event -> Open Document (Mac)

            Thanks  PhilModJunk. I tried that first. Didn't work. Which is why I thought I needed "GetField".

            • 3. Re: Send Event -> Open Document (Mac)

              If "file.pdf" works and the reference to user_View::file name does not, then you need to do some investigating:

              Confirm that File Name is of type text in Manage | database | fields

              Confirm that "file.pdf" is really the data in the field and that it's exactly the same as what you used in quotes. (but no quotes in this field)

              Make sure that your script is on the correct layout and correct current record at the time it executes and that the correct record in user_view is accessible at that time. You may want to use the data viewer and the script debugger to check this if you have FileMaker advanced. If you do not, you can put a show custom dialog step just before send event and put user_view::file Name in the dialog so that it pops up and displays the value of this field jsut before the send event step executes.

              • 4. Re: Send Event -> Open Document (Mac)

                OK, did all of that. Still nothing. I'm wondering if Preview is having a problem with the text of the request. I found the following, but am cluseless how to translate that into a script step(s).

                When sending an Open Document Apple Event from FileMaker Pro 2.0vx and later, most applications require that the document be selected via the Specify File button. FileMaker Pro allows a text field value or script text to be sent with an 'odoc' event, which would allow a document's path to be sent as the parameter. However, Apple Event standards indicate that the parameter of an Open Document ('odoc') event be an alias to the file. Using the Specify File button will set the file's alias as the parameter of the 'odoc' event, ensuring a proper apple event.

                Some applications (AppleWorks 5.0 for example) support custom parameters which may allow you to send the path of a document. It is for this reason that FileMaker Pro allows text to be passed in an 'odoc' event. You should be aware that sending an incorrect parameter in an apple event, such as a text field value when the receiving application expects the file's alias, may produce unexpected results.

                • 5. Re: Send Event -> Open Document (Mac)

                  I've been wondering if "file.pdf" was sufficient info here as there's no path to the file specified, but you've indicated that it works for you. If the data in literal quotes works, then referring to a text field that stores exactly the same text should produce identical results here...