Title: Re: Filemaker, Eudora, Applescript together
At 12:31 PM -0400 4/29/08, Sally Lawrence wrote:
Joe - Thanks very much for taking the time to look at this and post the fix. I have a couple of quesitons (I don't know much at all about Applescript!).
Does "DB_Name" need to include the .fp7 extension? (as in BKInquiries.fp7) ?

 No, and it wont if you pick it up this way. The two lines I use are:

        set dbName to name of front window

which gives the dbName as --> "EE1813_2008_Winter"

which you will note has not got the extension.

I then get a reference to the database and use that as the database object reference, which shortens your subsequent references...

        set theDB to a reference to database dbName


And I'm not sure I understand anything from "Even better..." on (below). Does the part that follows that replace something in the exisiting applescript commands?

 He's trying to tell you that you can populate a record at the time you create it if you have a properly ordered list with the values for the fields. So you can replace this from the script:

  create new record
               set data of cell "InquiryName" of last record to iName
               set data of cell "EmailReplySubject" of last record to iSubject
               set data of cell "InquiryDate" of last record to iDate
               set data of cell "InquiryEmail" of last record to iEmail
               set data of cell "InquiryComment" of last record to iBody

with this:

set newRecord to create new record with data dataList at table "TableName" of database "DB_Name"

iff you have the variable "datalist" populated with the requisite values.

so, for example, if your fields are defined in the order {LastName, First Name, age} you could make the new record and populate it at the same time if you did this first.

set datalist to {"Doe", "John", 35}

then this

set newRecord to create new record with data dataList at table "TableName" of database "DB_Name"

It removes a lot of lines from your script.

 - web


thanks again!
Sally
A small change in the "tell FileMaker Pro" part should fix it.

tell application "FileMaker Pro" - delete this line
               create new record at table "TableName" of database "DB_Name"
               set data of cell "InquiryName" of last record of table "TableName" to iName
               set data of cell "EmailReplySubject" of last record of table "TableName" to iSubject
               set data of cell "InquiryDate" of last record of table "TableName" to iDate
               set data of cell "InquiryEmail" of last record of table "TableName" to iEmail
               set data of cell "InquiryComment" of last record of table "TableName" to iBody
end tell - delete this line

AppleScripts run from within FileMaker don't need the "tell FileMaker, end tell" lines. FileMaker assumes everything is is directed at it unless otherwise specified.

Even better, but FileMaker's fields need to be in the same order as the data list, is the "create record with data" command which handles all of the data in one squirt.

set dataList to {InquiryName, EmailReplySubject, InquiryDate, InquiryEmail, InquiryComment}
--tell application "FileMaker Pro"
set newRecord to create new record with data dataList at table "TableName" of database "DB_Name"
--end tell

HTH
Joe

>(...I am sorry if this is a duplicate post. I inadvertantly posted from one of my other email addresses and I'm not sure if that will get "sent" or not since I am not registered with the list under that address.
>Sorry!)
>
>Hi all,
>Thanks so much. I wasn't sure if I should post the script. This script runs from the Filemaker file (called BKInquiries):
>
>Set Error Capture (on)
>Show All Records
>Show Omitted Only
>Freeze Window
>Go to Layout ("Applescript")
>Peform AppleScript (see below for details)
>Go to Layout (original layout)
>Go to Record/Request/Page (First)
>Loop
>Set Field (BKInquiries::InquiryDate; (Right(BKInquiries::InquiryDate; Length(BKInquiries::InquiryDate) - (Position(BKInquiries::InquiryDate; "M "; 1; 1) + 1))
>Set Field (BKInquiries::EmailReplySubject; (Case(Left(BKInquiries::EmailReplySubject; 3) = "Re:"; BKInquiries::EmailReplySubject; "Re: " & BKInquiries::EmailReplySubject)
>Set Field (BKInquiries::InquiryEmail; (Trim(BKInquiries::InquiryEmail)
>Go to Record/Request/Page (Next; Exit after last)
>End Loop
>Go to Record/Requst/Page (first)
>
>
>This is the text of the Applescript:
>tell application "Eudora"
>     set theMailbox to "In"
>     set numMessages to count every message of mailbox theMailbox
>     repeat with msgNum from 1 to numMessages
>          set msg1 to (a reference to message msgNum of mailbox theMailbox)
>          set address to field "From" of msg1
>          set aa to the offset of "<" in address
>          if (aa ’ 0) then
>               set az to the offset of ">" in address
>               if (az ’ 0) then set address to text (aa + 1) thru (az - 1) of address
>          else
>               set aa to offset of ":" in address
>               set az to (offset of "(" in address) - 1
>               if az = 0 then set az to length of address
>               set address to text from (aa + 1) to az of address
>          end if
>          set iName to sender of msg1
>          set iSubject to subject of msg1
>          set iDate to message date of msg1
>          set iEmail to address
>          set iBody to field "" of msg1
>          tell application "FileMaker Pro"
>               create new record
>               set data of cell "InquiryName" of last record to iName
>               set data of cell "EmailReplySubject" of last record to iSubject
>               set data of cell "InquiryDate" of last record to iDate
>               set data of cell "InquiryEmail" of last record to iEmail
>               set data of cell "InquiryComment" of last record to iBody
>          end tell
>          log numMessages - msgNum
>     end repeat
>end tell






**************
Need a new ride? Check out the largest site for U.S. used car listings at AOL Autos.
(http://autos.aol.com/used?NCID=aolcmp00300000002851)

Reply via email to