Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3195 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted (edited)

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 by Steve Martino
corrected typo in script
Posted

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?

Posted

There was a typo in my original.  Should be:

"$path.pdf"

Export Field Contents [ PSWorkflow::PSWF_OrderPDF; “$path.pdf”; Automatically open ]

Posted

I don't think so. 

Should be:

Export Field Contents [ PSWorkflow::PSWF_OrderPDF; $path ; Automatically open ]

Posted (edited)

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.

 

pdfSS.png

Edited by Steve Martino
Posted

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.

Posted

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 

script.png

ExportPDF.fmp12

And if earlier suggestions DID work, you would end up with a file name myFileName.pdf.pdf

Posted (edited)
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 by ggt667
Posted

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?

Posted

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.

Posted

Post your file; or print your script to PDF and copy the entire content of the script and post it.

Posted

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?

Posted
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?

Posted

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...

Posted

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

Posted

"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.

This topic is 3195 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.