The file paths need to include the full path. A relative path, as far as I know, won't work with these two steps (send event and open url). You'd need to compute the full path starting from the drive letter (windows) or volume name ( macs).
You could insert the file into a container field with "store by reference" to enable a relative path to the document. You can open said document by double clicking the container field or by using Enter Field or Export Field Contents in a script. You can also use a web viewer to view the PDF, but you still have to compute the full path to the document in the Viewer's URL expression.
There's also a third party add on, called supercontainer that you can investigate.
Martin, I have done something similar. In order to make it work I set up the text field with the calculated filepath as you did. One of the keys was to ensure that the file is stored to a folder that everyone can access and that it is stored as a reference. From Jim's computer the path may be desktop/file.pdf, but when John goes to open desktop/file.pdf he gets a file not found error. To do this I made a script that is triggered on modifying the container that takes the file and exports it to a specific location on the server, then replaces the contents with that exported version of the file (as reference). That way the user does not have to select the save as reference and the file will be on the server for all users to find. Then to make it cross-platform you will need to make the open file script determine the platform type and substitute filemac: or filewin" as appropriate. I did this by defining a filepath variable and setting it to a calculated result based on the platform and the filepath field for the container.
A useful function for computing the full path equivalent to a relative file path (path to a file in the same directory as the database file) is Get (filepath).
Mark and Phil,
Thanks for the input. I have done some quick testing but Mark I'm not sure I am fully grasping your concept. I have a folder with hundreds of pdf files (oddly enough named pdfs). It will be located with the main file since it will be used primarily as a runtime version. So if I understand correctly I will have to import the file into the container field which because it has been modified will then trigger a script that will export the file; again in my case to the pdf folder, leaving behind the file as a reference. Another calculated script defining the file's location is then used by Send Event to retrieve (from folder pdf) the file and open using the assigned application. The file path based needs to be the complete file path as well as Mac/Win for cross platform functionality. It appears to me that I still need to import the files one by one to create the reference. Looks like I'll need to design a script to automate that part a bit.
Well I'm going to puzzle over this for awhile, other things have landed on my plate that I need to address. I currently have other ways of accessing the same information and this was a " ...wouldn't it be neat if I could ...." marry the two mostly for fun and learning challenge. The FMP community is amazing and I love the program - now if I could only learn how to really use it!
In my application, I needed a place for the users to place files received with requests for quotes. I wanted to be able to place those files in containers related to the quote record so that anyone reviewing the quote at a later date would be able to view those associated files. I set up the container field to run the "filestore" script on modification. That script takes the file that is inserted in the container field and saves it to a folder on the server (in my case the folder is determined by a variable since there are folders for each customer). I also modify the file name by adding the quoteID number to the front of the filename, since sometimes we get files with the same name. The script then replaces the originally inserted file with the modified version from the server with the "as reference" option. This ensures that the file is inserted as reference whether the userr selects that option or not and places the file in a location that everyone will have access to.
Then there is a text field that is a calculated value of that container field. When you look at that text field is something like this
I then set up a button to open that file using a script where I set a variable to a calculated value that uses the file path from that field, modified for the user's platform.
It would take a little wrangling modifying a DB that already has the files in the container fields, but I'm sure you could write a little temporary loop script that goes through each record and moves the files. From then on any additional records/files with be done as they are inserted.