Hi All.
I have a strange issue with the script below. My client wants to drag a PDF into a container field (works great), automatically create a cover page, merge the two with the cover page on top and place the new PDF into a different container field. I export the original PDF to the temp directory, export a cover page PDF to the temp directory and then run a command line line app called pdftk to merge the two. All of the files are in the temp directory including the newly merged one. Everything works great until the Insert File script step. When Filemaker hits the Insert File step it will:
1) Work
2) Appear to work but nothing is inserted into the other container field
3) Bring up the insert file dialog
Obviously #1 is what I want all of the time. Does Filemaker have an issue with the temp directory perhaps? Is there something I'm missing? I've also tried using Insert PDF but that has been even less reliable.
BTW, I'm using FM 13 and the clients DB is a hosted FM server 13.
Set Error Capture [On]
#
# Variables
#
Set Variable [$X; Value:Inquiries::ClientRecords Temp]
Set Variable [$TempRecord; Value:Get ( TemporaryPath ) & GetAsText ( Inquiries::ClientRecords Temp )]
Set Variable [$TempSave; Value:Get ( TemporaryPath ) & "Temp Save.pdf"]
Set Variable [$TempPath; Value:Get ( TemporaryPath )]
Set Variable [$Litserv; Value:Inquiries::LitServ#]
#
Export Field Contents [inquiries::ClientRecords Temp; “$TempSave”]
#
New Window [style: Document]
Go to Layout [“Records Cover Page” (Inquiries)]
Enter Find Mode []
Perform Find [Restore]
Set Variable [$FaxCover; Value:Get ( TemporaryPath ) & "Fax Cover.pdf"]
Save Records as PDF [No dialog; “$FaxCover”; Records being browsed]
#
Set Variable [$Execute; Value:"cmd.exe /C pdftk "" & $FaxCover & "" "" & $TempSave & "" cat output "" & $TempRecord & """]
Set Variable [$Execute; Value:Substitute ( $Execute; "/"; "" )]
Set Variable [$Execute; Value:Substitute ( $Execute; "C:"; "C:" )]
Set Variable [$Execute; Value:Substitute ( $Execute; "cmd.exe C"; "cmd.exe /C" )]
Set Variable [$NewPDF; Value:Right ( $Execute ; Length ( $Execute ) - Position ( $Execute ; " " ; Length ( $Execute ) ; - 1 ))]
Set Variable [$NewPDF; Value:"filewin:" & $TempRecord]
Send Event [“aevt”; “odoc”; $Execute]
#
Go to Layout [“Inquiries Raw” (Inquiries)]
Go to Field [inquiries::ClientRecords]
Insert File [inquiries::ClientRecords; “$NewPDF”]
Close Window [Current Window]
#
Set Variable [$Exit_Script; Value:"Pause"]
Thanks