AnsweredAssumed Answered

Emailing / attaching a generated PDF

Question asked by CameronL. on Aug 23, 2012
Latest reply on Aug 24, 2012 by CameronL.

Title

Emailing / attaching a generated PDF

Post

Hi all.

I'm running into a problem trying to run a script to dynamically generate a PDF of a list of records in an Invoice layout, and create an email with that PF automatically attached. Here's my script:

If [Get ( SystemPlatform ) = 3]
     Go to Related Record [Show only related records; From table: "Measures_Add_Products"; Using layout: "HD Measure" (Measures_Add_Products); New window]
     # Set page count
     Go to Record/Request/Page [Last]
     Set Field [Measures_Add_Products::Page Count; Get ( Page Number )]
     Go to Record/Request/Page [First]
     #
     Set Variable [$FileName; Value:"Measure PO# " & Measures::PO# & " - " & Customers::NameFull_LastFirst & ".pdf"]
     Save Records as PDF [Restore; No dialog; "$FileName"; Records being browsed]
     Set Variable [$PDFPath; Value:Get ( DocumentsPath ) & $FileName]
     Send Mail [Send via E-mail Client; Subject: $FileName; Message: "Here's your invoice"; "$PDFPath"]
Else
     Go to Related Record [Show only related records; From table: "Measures_Add_Products"; Using layout: "HD Measure" (Measures_Add_Products); New window]
     # Set Page Count
Enter Preview Mode []
     Go to Record/Request/Page [Last]
     Set Field [Measures_Add_Products::Page Count; Get ( Page Number )]
     Go to Record/Request/Page [First]
     #
     Set Variable [$FileName; Value:"Measure PO# " & Measures::PO# & " - " & Customers::NameFull_LastFirst]
     Save Records as PDF [Restore; No dialog; "$FileName"; Records being browsed]
     Set Variable [$PDFPath; Value:Get ( TemporaryPath ) & $FileName]
     Send Mail [Send via E-mail Client; Subject: $FileName; Message: "Here's your invoice"; "$PDFPath"]
End If
 

The script is written to detect whether the user is using FileMaker Pro on the computer or FileMaker Go on the iPad, and makes a couple minor file path and file extension changes. I've highlighted the differences in the If/Else statement in blue.

The script works fine in Filemaker Go on the iPad but does not work on Filemaker Pro on my Mac.

Does anyone have any idea what I'm doing wrong here? Help is greatly appreciated.

Thanks!

Outcomes