Newbies CoryHolden Posted July 22, 2015 Newbies Posted July 22, 2015 (edited) I am a new user of Filemaker (with some previous Java experience) trying to create a searchable project database for a contract furniture dealer. One of the features I feel would be very valuable is the ability to append any type of file (though most likely .pdf or .doc) to the project, and have the end user be able to open the file in Adobe Reader/Word/etc. simply by clicking on a button somewhere. I'm trying to use the Open URL script to accomplish this, and while I can get my script to open a file I specify in the script (such as "C:/Users/me/Documents/test.doc"), I'm having trouble formatting my script to open this file (ie, database location/database name/table name/container name/file name). The pertinent information is structured like so: Filemaker File is named SampleDatabase3.fmp12 FileMaker File is contained in F:\Sales & Marketing\Neocon 2015\Digital database test Quote::Quote File - Container (External: Open Storage: Relative to: [database location]/SampleDatabase3 Quote::Quote File Path - Text And the script I currently have is set up like so: #Opens the attached file in whatever default program is available. Set Field [Quote::Quote File Path; Let ( [intermediateXtractionString = RightValues(GetAsText(Quote::Quote File); 1); xtractionString = Right(intermediateXtractionString; Length(intermediateXtractionString)-5)] ; "file://F:/Sales & Marketing/Neocon 2015/Digital database test/Sample Database3/" & xtractionString ) ] Open URL [No Dialog; Quote::Quote File Path] The idea is that treating a container as a text field (either by using GetAsText() or simply passing it into a function that expects a text parameter) displays this: remote:test.doc FILE:Quote/Quote Field/test.doc Thus, the Let statement gets the last line (minus the "FILE:" characters) and appends it to what (should be) a valid file path. After I run this script, Quote::Quote Field Path contains "file://F:/Sales & Marketing/Neocon 2015/Digital database test/Sample Database3/Quote/Quote File/Outlook Export Test.CSV", and the Open URL statement does nothing - nothing opens, no error messages, nothing at all, despite the fact that manually copy-pasting this URL into Firefox opens the file. Should I be using Send Event instead of Open URL? Is my syntax wrong? Or is there something I'm not seeing? Edited July 22, 2015 by CoryHolden
Wim Decorte Posted July 22, 2015 Posted July 22, 2015 How about the "export field contents" script step with the "automatically open" toggle on?
Newbies CoryHolden Posted July 23, 2015 Author Newbies Posted July 23, 2015 (edited) How about the "export field contents" script step with the "automatically open" toggle on? That works beautifully. Will this work regardless of the settings of the container, or does it have to be stored externally? Edit, for those curious about my code; Set Variable [$extension; Value: Let ( [intermediateXtractionString = LeftValues(GetAsText(Quote::Quote File); 1); xtractionString = Right(intermediateXtractionString; Length(intermediateXtractionString)-7)] ; Right(xtractionString; Length(xtractionString)-Position ( xtractionString ; "." ; 1 ; 1 )+1) )] Set Variable [$extension; Value: "Output" & $extension] Export Field Contents [Quote::Quote File; "$extension"; Automatically open] It could stand to be cleaned (I certainly don't need two Set Variable statements), and if I wanted to, I could probably pass in the specific field I want with GetParameter() so I could use this in multiple layouts, but it's functional and it does exactly what I want it to do. Best of all, because all of the files are named "Output", Filemaker overwrites them when it exports them, so you're not saving the entire database to one place (at most, you'll have one file of every extension in whatever location you specify. If you're trying to use this and you want to save a copy of everything, you can use "xtractionString" instead to get the full file name. Edited July 23, 2015 by CoryHolden added code
Recommended Posts
This topic is 3677 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now