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

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

Recommended Posts

Posted

I need a script to send an email to a person and take, at random, the text out of a specific field in a FMP 8 data base.

I am not good at scripting and so far my attempts have failed.

Does anybody have any ideas?

Here is the mail script I use that works fine to sent fixed text:

set theSubject to "Subject text" --change me

set theBody to "Body text" --change me

set theTarget to "[email protected]" --change me

tell application "Mail"

set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody}

tell newMessage

make new to recipient at end of to recipients with properties {address:theTarget}

set sender to "Me " --change me

end tell

send newMessage

end tell

but not sure how to get to the field in in my data base and select one randomly.

Posted

Why don't you use send mail script step? As I remember, it was added with version 7.

Posted

I want to use my mailing list to send a quote every day from my FMP database. I think this can only be done from the outside of the DB as it contains no email addresses.

so the mail script step would not help.

Posted

fixed that by using:

end tell

tell application "FileMaker Pro Advanced"

	show every record in database "Quotes" -- works	

still not sure how to get it to select a random record and copying it.

BTW, rest of your code does not work either. hangs already on the field/layout selection.

Posted

oops did not realise.

Go to Record [ Ceiling ( Random * Get (FoundCount) ) ]

does not work.

Get: Specified field table can not be found
Posted

I am not sure what you're doing. You need to open Scriptmaker and create a new script with the steps I have outlined. In the step Go to Record (or more precisely, Go to Record/Request/Page), specify 'By calculation...', and enter:

Ceiling ( Random * Get (FoundCount) )

into the calculation window.

Posted

yes, I am in Scriptmaker and have made a new script.

Now I understand your instructions and it works. Not sure what I did wrong so far, but never mind, thanks for your patience.

however I need to enter a number and would like it to be automatically and random generated. Is this possible?

Posted

You could have the Filemaker script run your Applescript as its final step. If you want to run this from "outside", have your Applescript call the FM script, then proceed with the data from the current record.

Posted

thanks for your help comment,

in case anybody else is following this and interested, here is the Applescript that works, adjust as needed to point to the FMP file and where ever you want to paste it to.

I activated the script in FMP8, by giving it 'CMD 1' as a key command.

So the Applescript triggers the FMP script and takes the copied contents and pastes it, in this case in a new TextEdit document.

tell application "Finder"

activate

open document file "X" of folder "Y" of disk "Z"

tell application "System Events"

tell application "FileMaker Pro Advanced" to activate

keystroke "1" using command down

end tell

end tell

delay 3

try

set the clipboard to Unicode text of (the clipboard as record)

on error errMsg

display dialog errMsg

end try

tell application "TextEdit"

activate

delay 0.5

tell application "System Events"

key code 48 using {command down}

key code 9 using {command down}

end tell

end tell

Posted

Why not simply something like:

tell application "FileMaker Pro Advanced"

open "HD: ... Quotes.fp7"

do script "Random Quote"

set dailyQuote to cellValue of cell "Quote" of current record

end tell

tell application "Another Application"

set some object to dailyQuote

...

I am not sure that's the correct syntax - all I am trying to say that you can address objects directly, instead of trying to emulate mouse clicks and keyboard presses.

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