Jump to content

Insert file script step problems

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

Recommended Posts

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"]
Link to comment
Share on other sites

As Comment indicates: FM does not wait for the result of the Send Event step, it just forges on, so timing is a big issue here.  You can do an arbitrary pause (as long as you make it long enough to cover all eventualities) or you can make the external scripting more complex in that  your scripts at the Send Event and the external routine calls back to FM when it is done.  You can use a URL with the FMP protocol for that...

Link to comment
Share on other sites

This topic is 2936 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.