February 19, 20169 yr Hi All, I have a container field holding a pdf and would like to run a script upon a button click that opens it in its native program or app. in this case Adobe Reader. Can anyone help with writing a script for this? I am lost and very new to FMPro. Cheers Simon
February 20, 20169 yr Simple way is to export to temporary path. Here's one I use to take a letter sent to a customer, saved in a container, for viewing or printing. These are the basic steps: Set Variable [$path; Value: Get(TemporaryPath) & "Letter_" & Customers::Name_last & ".pdf"] Export Field Contents [Customer_contact::Letter; "$path.pdf"; Automatically open] edit: corrected typo Edited February 21, 20169 yr by Steve Martino corrected typo in script
February 21, 20169 yr Author Here is the script that I created using your example. Set Variable [ $path; Value:Get(TemporaryPath) & "Order_" & GeneralAccounts::GeneralAccName & ".pdf" ] Export Field Contents [ PSWorkflow::PSWF_OrderPDF; “file:File[$path].pdf”; Automatically open ] Unfortunateley the script will only let me place “file:File[$path].pdf” in double speech marks and not just the one at the start of it as your script indicates. I think therefore my script will only name the file File[$path].pdf and not "Order_" & GeneralAccounts::GeneralAccName & ".pdf" . Any thoughts?
February 21, 20169 yr There was a typo in my original. Should be: "$path.pdf" Export Field Contents [ PSWorkflow::PSWF_OrderPDF; “$path.pdf”; Automatically open ]
February 21, 20169 yr I don't think so. Should be: Export Field Contents [ PSWorkflow::PSWF_OrderPDF; $path ; Automatically open ] Like this
February 21, 20169 yr I copied that line from the script (has the quotes). But when I look in Specify Output File dialog, it looks like this: file:$path.pdf PS I cant get your "like this" button to open, throws an error. Edited February 21, 20169 yr by Steve Martino
February 21, 20169 yr Your $path variable should already have the .pdf on the end, and then you can just use $path I don't believe you can mix variables and text for the Output file.
February 21, 20169 yr Agree with webko. Set Error Capture [ On ] Set Variable [ $filename; Value:ExportPDF::BaseFileName & ".pdf" ] Set Variable [ $path; Value:Get( DesktopPath) & $filename ] Export Field Contents [ ExportPDF::PDFContainer; “$path”; Automatically open ] Set Variable [ $error; Value:Get( LastError) ] Set Field [ ExportPDF::ExportResult; $error ] Commit Records/Requests ExportPDF.fmp12 And if earlier suggestions DID work, you would end up with a file name myFileName.pdf.pdf
February 22, 20169 yr On 19 February, 2016 at 0:50 AM, MutantST said: I have a container field holding a pdf and would like to run a script upon a button click that opens it in its native program or app. in this case Adobe Reader. FYI: I would use FireFox or Chromium as PDF-viewer Edited February 22, 20169 yr by ggt667
February 22, 20169 yr Author Cheers, for your input everyone. the BruceR script returned this error: “remote:Print.pdf” could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk. and result 800?
February 22, 20169 yr Where does the text "remote:Print" come from? Is that the contents of the field you're taking the file name from? That's not going to work: a file name cannot contain a colon or a slash.
February 22, 20169 yr Post your file; or print your script to PDF and copy the entire content of the script and post it.
February 22, 20169 yr Author The Jpeg below (Open Order Form) is no longer returning the error, but the filename is being named : "remote/SmithOrderForm.pdf". Just wondering why the word remote is showing up in the named file? Edited February 22, 20169 yr by MutantST script input fail :)
February 22, 20169 yr Author Actually, the files path is showing remote:SmithOrderForm.pdf FILE:OrderForms/SmithOrderForm.pdf Would this be because the FMPro File is stored in a dropbox folder?
February 22, 20169 yr You are using the same container field being exported to name the exported file. See: http://www.filemaker.com/help/14/fmp/en/html/func_ref1.32.239.html#1075526
February 22, 20169 yr Author 55 minutes ago, comment said: You are using the same container field being exported to name the exported file. See: http://www.filemaker.com/help/14/fmp/en/html/func_ref1.32.239.html#1075526 Yeah, that is what I am going for. 1 hour ago, webko said: My guess is because it is an external stored Container field. So it looks like I have to have the file stored internally to remove the remote part. Oh well, suppose I can put up with that. Will this script work if I use a different file type? say a word doc?
February 22, 20169 yr Well, no you don't need to store it internally - you can use the function referenced above to get the values, and then manipulate the data to remove the "remote:" before creating the path...
February 23, 20169 yr Author 43 minutes ago, webko said: manipulate the data to remove the "remote:" before creating the path... Not sure how to do this :/
February 23, 20169 yr Author Nothing, sorry. I know, how cool would that of been. I did try it first off but for some reason it does not work.
February 23, 20169 yr Do this google search site:fmforums.com Extracting Filename from Container link The file "Extracting Filename from Container link” was posted in Feb 2010 and is very helpful for see the file paths, In addition, there were several other hits that many also come in handy. Lee
February 23, 20169 yr "Not sure how to do this :/" Then - for test purposes anyway - just create a new, plain text field and enter text into it and use THAT for your export/open script.
Create an account or sign in to comment