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

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

Recommended Posts

Posted

I have a script which saves a PDF to a predetermined folder on the server - attaches it via email then copies the PDF to a folder of the users choice (selected using apple script - "choose folder with prompt…"). Works ok except the time it takes to save across a remote network.

So if i could reverse the save order, creating the PDF to the users choice folder first and make the save back to the server later in the background it would all be much smoother.

But I am not sure how the mail script step can find the users selected folder and can I make the copy process in the background and not hold up filemaker. Thanks hope that makes sense.

Posted

If you let AppleScript choose the path, then write it back to a field in FileMaker, then it can be used (after converting to FileMaker syntax) by the Send Mail step. You could send the email, then copy the file to the server. I don't know how much that would slow down FileMaker. It would be running the AppleScript, but the Finder, or Unix, would be doing the copying. It seems (to me) it would be faster than putting it on the server first.

Posted

Thanks Fenton - that is what i thought. Im doing something dumb here and cant get a FM cell to take on a value. Any ideas?

tell application "FileMaker Pro Advanced" to set file_name to cell "minutes::filename" of current record

set new_folder to (choose folder with prompt "Choose a Project Folder to save the PDF file: " & file_name)

tell application "FileMaker Pro Advanced" to set cell "meeting::gtext" to new_folder

Posted

The problem with the above is that the choose folder command returns an "alias", not text. An alias is a fully functional AppleScript reference to the file, to be used in further commands. But it is not text and cannot be set into a FileMaker text field. But it can be easily converted to text, by simply adding "as Unicode text".

(Actually in Leopard I believe you can just say "as text" and it is all Unicode text. But I'm still in Tiger, so I need to specify Unicode. Either can be used in Leopard.)

set cell "meeting::gtext" to new_folder as Unicode text

Also, if you're running this in a Perform AppleScript step inside FileMaker, you do not need:

tell application "FileMaker Pro Advanced"

FileMaker knows who it is. If you're running it outside FileMaker, as an external AppleScript, you do need it; but you only need it once. You can include the "choose folder" command within a FileMaker tell block. Some commands, like "write" to file do not work within a FileMaker tell block, but most do.

[P.S. The fields above must be on the current layout if you specify them just by name. They do not if you specify them by layout. You can also incorporate an "error capture" within the AppleScript, using a "try" block. You want to tell them if there's an error, but not if it's error -128, which is "user cancelled". Here's some ideas in the attached file. You could also use the standard FileMaker, Set Error Capture ["On"]. AppleScript errors are seen by that also.]

ChooseFolder.fp7.zip

Posted

[P.S. The fields above must be on the current layout if you specify them just by name. They do not if you specify them by layout. You can also incorporate an "error capture" within the AppleScript, using a "try" block. You want to tell them if there's an error, but not if it's error -128, which is "user cancelled". Here's some ideas in the attached file. You could also use the standard FileMaker, Set Error Capture ["On"]. AppleScript errors are seen by that also.]

I prefer to set a global field and use a table reference. Then you do not need to refer to the current records and the fields do not have to be on the layout. See attached.

chooseFolder.zip

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