Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Insert file script step problems

Featured Replies

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

Is it possible that you need to allow some time for the event to execute? Like pause the script for a few seconds, or place it in a loop until you can get some confirmation?

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.