Re: FileMaker Pro 8 and Do Scripts Errors!
Re: FileMaker Pro 8 and Do Scripts Errors!
- Subject: Re: FileMaker Pro 8 and Do Scripts Errors!
- From: "Gary (Lists)" <email@hidden>
- Date: Mon, 26 Sep 2005 11:11:56 -0400
"Jason Bourque" wrote:
> I get this error when trying to set cell data after a do script call. Any
> Ideas?
I am a fan (and advocate) of the 'Do Script' command. However, I don't
think is an efficient use of that command.
1. Check the syntax. Unless it changed in FM8, the actual command in all
prior versions was:
Do Script FileMaker Script "New Record"
(You don't get a syntax error, so it's probably changed...which is
good...the command was always stupidly redundant in its name anyway.)
2. Do Script is really intended as a means to 'marry' the internal FM
scripting engine (Script Maker) with AppleScript. It's best used when you
want to invoke some 'custom action' or do from outside FM what your users
could do from inside (via a button, for example.)
Using 'Do Script' to make a new record is inefficient on several levels.
> "FileMaker Pro got an error: Data is being accessed by another user, script,
> or transaction."
(FYI, FM does have transactional locking via AS. That is _not_ what you need
here, but just so you know you can wrap blocks in a 'transaction'.)
> tell application "FileMaker Pro 8"
> activate
>
> tell database "To Do List.fp7"
>
> do script "New Record"
>
> delay 1
>
> tell window 1
> tell current record
> set cell "Task Name" to vTextSelection
> set cell "Requested By" to vSendersFirstName
> set cell "Task History" to vEmailContent
> end tell
> end tell
> end tell
> end tell
No good. Too long. ;)
Here is a much more efficient and short AS to do the same task.
--
tell application "FileMaker Pro"
go to (create new record at end of records with data {vTextSelection,
vSendersFirstName, vEmailContent})
end tell
--
That will do the creation and put you at that new record. You will need to
know the field order on the layout, as that is the order of the values in
the list you pass.
You can wrap more 'tell' blocks, if needed for specificity. Like by adding:
...
tell app "FileMaker Pro"
tell current layout -- if needed, for example
-- or: tell current record -- if needed
...
And, just to be clear about the returned result of a 'create new record'
(which is a record ID), you can see how it works here:
--
tell application "FileMaker Pro"
go to record ID (ID of (create new record))
end tell
--
That will create a new rec and take you there (otherwise, records get
created but you do not 'move' to the new record for targeting purposes (nor
do you move there visually in the DB.)
HTH
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden