dbTalk Databases Forums  

script trigger problem

comp.databases.filemaker comp.databases.filemaker


Discuss script trigger problem in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bill Steele
 
Posts: n/a

Default script trigger problem - 01-17-2011 , 05:20 PM






I have a script that reads a text field, the performs an Applescript to
process the information and use ti to set a couple of other fields. It
runs fine as an Applescript ij Script Editor using "Tell application
Filemaker Pro." But when fired with a script trigger on exit from the
source field I get error messages "Data is being accessed by another
user, script...etc." when it tries to set the other cells. That error
usually comes up when the record is not committed, but the onExit
trigger only works after you have clicked out of the field. So what is
it complaining about?

Reply With Quote
  #2  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: script trigger problem - 01-17-2011 , 10:53 PM






On 1/17/2011 3:20 PM, Bill Steele wrote:
Quote:
I have a script that reads a text field, the performs an Applescript to
process the information and use ti to set a couple of other fields. It
runs fine as an Applescript ij Script Editor using "Tell application
Filemaker Pro." But when fired with a script trigger on exit from the
source field I get error messages "Data is being accessed by another
user, script...etc." when it tries to set the other cells. That error
usually comes up when the record is not committed, but the onExit
trigger only works after you have clicked out of the field. So what is
it complaining about?

It's complaining because Applescript accesses the database as an
external query/command. It cannot make changes to a record that
FileMaker already has open/locked.

Is there a reason you are using an external tool like Applescript rather
than FileMaker's own Scriptmaker?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc. Los Angeles

FileMaker Certified Developer
Associate Member, FileMaker Business Alliance

Reply With Quote
  #3  
Old   
Agi
 
Posts: n/a

Default Re: script trigger problem - 01-18-2011 , 10:09 AM



On Jan 17, 11:53*pm, Howard Schlossberg
<how... (AT) nospam (DOT) fmprosolutions.com> wrote:
Quote:
On 1/17/2011 3:20 PM, Bill Steele wrote:

I have a script that reads a text field, the performs an Applescript to
process the information and use ti to set a couple of other fields. *It
runs fine as an Applescript ij Script Editor using "Tell application
Filemaker Pro." But when fired with a script trigger on exit from the
source field I get error messages "Data is being accessed by another
user, script...etc." when it tries to set the other cells. That error
usually comes up when the record is not committed, but the onExit
trigger only works after you have clicked out of the field. So what is
it complaining about?

Try using two triggers. First trigger onmodify to grab the field value
in a global variable. Then second trigger on save runs your script and
uses the global variable. Don't forget to clear the global variable
when done with it.


Quote:
It's complaining because Applescript accesses the database as an
external query/command. *It cannot make changes to a record that
FileMaker already has open/locked.

Is there a reason you are using an external tool like Applescript rather
than FileMaker's own Scriptmaker?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc. * *Los Angeles

FileMaker Certified Developer
Associate Member, FileMaker Business Alliance

Reply With Quote
  #4  
Old   
Bill Steele
 
Posts: n/a

Default Re: script trigger problem - 01-18-2011 , 12:14 PM



In article
<f0caf2ff-e091-48ed-a0cd-ffb5e1c12d37 (AT) o9g2000pre (DOT) googlegroups.com>,
Agi <ariley (AT) gmail (DOT) com> wrote:

Quote:
On Jan 17, 11:53*pm, Howard Schlossberg
how... (AT) nospam (DOT) fmprosolutions.com> wrote:
On 1/17/2011 3:20 PM, Bill Steele wrote:

I have a script that reads a text field, the performs an Applescript to
process the information and use ti to set a couple of other fields. *It
runs fine as an Applescript ij Script Editor using "Tell application
Filemaker Pro." But when fired with a script trigger on exit from the
source field I get error messages "Data is being accessed by another
user, script...etc." when it tries to set the other cells. That error
usually comes up when the record is not committed, but the onExit
trigger only works after you have clicked out of the field. So what is
it complaining about?

Try using two triggers. First trigger onmodify to grab the field value
in a global variable. Then second trigger on save runs your script and
uses the global variable. Don't forget to clear the global variable
when done with it.
I was thinking along those lines, but hadn't thought of using two
triggers. Do you mean using OnObjectSave on the global variable?

And doesn't the comment below still apply?
Quote:

It's complaining because Applescript accesses the database as an
external query/command. *It cannot make changes to a record that
FileMaker already has open/locked.

Is there a reason you are using an external tool like Applescript rather
than FileMaker's own Scriptmaker?
Lots of things Applescript can do that Scriptmaker never dreamed of. In
this case, a lookup from a list.

Reply With Quote
  #5  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: script trigger problem - 01-18-2011 , 02:00 PM



On 1/18/2011 10:14 AM, Bill Steele wrote:
Quote:
Lots of things Applescript can do that Scriptmaker never dreamed of. In
this case, a lookup from a list.
While the first part of that statement may or may not be true, I'd like
you to elaborate on the second part of your statement please.

Please provide an example of looking up from a list. Is the list
represented by records? What is the list format and how many values in
the list? I'd bet there's a custom function or other calc that could do
what you want.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc. Los Angeles

FileMaker Certified Developer
Associate Member, FileMaker Business Alliance

Reply With Quote
  #6  
Old   
Your Name
 
Posts: n/a

Default Re: script trigger problem - 01-18-2011 , 02:06 PM



"Howard Schlossberg" <howard (AT) nospam (DOT) fmprosolutions.com> wrote

Quote:
On 1/18/2011 10:14 AM, Bill Steele wrote:
Lots of things Applescript can do that Scriptmaker never dreamed of. In
this case, a lookup from a list.

While the first part of that statement may or may not be true, I'd like
you to elaborate on the second part of your statement please.

Please provide an example of looking up from a list. Is the list
represented by records? What is the list format and how many values in
the list? I'd bet there's a custom function or other calc that could do
what you want.
Even just a simple Relationship can be used to lookup from a list easily
enough.

Helpful Harry )

Reply With Quote
  #7  
Old   
Bill Steele
 
Posts: n/a

Default Re: script trigger problem - 01-19-2011 , 01:58 PM



In article <ih4rqo$knn$1 (AT) lust (DOT) ihug.co.nz>,
"Your Name" <your.name (AT) isp (DOT) com> wrote:

Quote:
"Howard Schlossberg" <howard (AT) nospam (DOT) fmprosolutions.com> wrote in message
news:ih4rg9$dr9$1 (AT) news (DOT) motzarella.org...
On 1/18/2011 10:14 AM, Bill Steele wrote:
Lots of things Applescript can do that Scriptmaker never dreamed of. In
this case, a lookup from a list.

While the first part of that statement may or may not be true, I'd like
you to elaborate on the second part of your statement please.

Please provide an example of looking up from a list. Is the list
represented by records? What is the list format and how many values in
the list? I'd bet there's a custom function or other calc that could do
what you want.

Even just a simple Relationship can be used to lookup from a list easily
enough.

Helpful Harry )
User types in "February." I want 2. Filemaker has a function to get a
month name from a date, but nothing that goes the other way. Yes, I
thought of creating table that just has the names and numbers, but that
seems like overkill. And I already had the Applescript code lying
around.

I may just tell people "Shut up and type in the date the other way."

Reply With Quote
  #8  
Old   
Your Name
 
Posts: n/a

Default Re: script trigger problem - 01-19-2011 , 02:42 PM



"Bill Steele" <ws21 (AT) cornell (DOT) edu> wrote

Quote:
User types in "February." I want 2. Filemaker has a function to get a
month name from a date, but nothing that goes the other way. Yes, I
thought of creating table that just has the names and numbers, but that
seems like overkill. And I already had the Applescript code lying
around.

I may just tell people "Shut up and type in the date the other way."
A separate Table isn't overkill ... using AppleScript is certainly overkill.
)

All you really need is a simple Case statement which can be used in a normal
FileMaker Script, Custom Function, Calculation Field, or Auto-enter
Calculation.
i.e.
Case(
(TypedMonth = "January") or (TypedMonth="Jan"); 1;
(TypedMonth = "February") or (TypedMonth="Feb"); 2;
(TypedMonth = "March") or (TypedMonth="Mar"); 3;
(TypedMonth = "April") or (TypedMonth="Apr"); 4;
... etc.
"INVALID MONTH"
)

The harder part might be extracting the month name's text from the entered
data since it can be entered in various ways, but that shouldn't be too
difficult.


A better input method might be to use a pop-up calendar for users to pick
the date from, then there's no way they can cause problems with their own
"unique" ways of writing dates.

Helpful Harry )

Reply With Quote
  #9  
Old   
Lynn Allen
 
Posts: n/a

Default Re: script trigger problemX-TraceApproved - 01-19-2011 , 03:59 PM



On 2011-01-19 11:58:13 -0800, Bill Steele <ws21 (AT) cornell (DOT) edu> said:

Quote:
User types in "February." I want 2. Filemaker has a function to get a
month name from a date, but nothing that goes the other way. Yes, I
thought of creating table that just has the names and numbers, but that
seems like overkill. And I already had the Applescript code lying
around.

I may just tell people "Shut up and type in the date the other way."
So what you do is create a date, and then enclose that in the MonthName
function like so:

MonthName ( Date(UserInput; 1; 2000))

Very simple, elegant and no need to be grubbing about in AS.

The year doesn't matter, since all years have the same months, and the
day doesn't matter, as long as it's in every month.

Never mind brute force tests. Explore your functions. They're all
listed in the Help with syntax and examples.
--
Lynn Allen
--
www.semiotics.com
Member FBA
FM 10 Certified Developer

Reply With Quote
  #10  
Old   
Lynn Allen
 
Posts: n/a

Default Re: script trigger problemX-TraceApproved - 01-19-2011 , 04:11 PM



On 2011-01-19 13:59:25 -0800, Lynn Allen <lynn (AT) NOT-semiotics (DOT) com> said:

Quote:
On 2011-01-19 11:58:13 -0800, Bill Steele <ws21 (AT) cornell (DOT) edu> said:

User types in "February." I want 2. Filemaker has a function to get a
month name from a date, but nothing that goes the other way. Yes, I
thought of creating table that just has the names and numbers, but that
seems like overkill. And I already had the Applescript code lying
around.

I may just tell people "Shut up and type in the date the other way."

So what you do is create a date, and then enclose that in the MonthName
function like so:

MonthName ( Date(UserInput; 1; 2000))

Very simple, elegant and no need to be grubbing about in AS.

The year doesn't matter, since all years have the same months, and the
day doesn't matter, as long as it's in every month.

Never mind brute force tests. Explore your functions. They're all
listed in the Help with syntax and examples.
Never mind that was the exact opposite of what you asked for. I think
today is Bizarro Wednesday.

I found this very clever custom function at www.briandunning.com called
MonthNumber:

Position (
"xxJanFebMarAprMayJunJulAugSepOctNovDec" ;
Left ( monthname; 3 ) ;
1 ;
1
) / 3

That monthname is the field your users input the date into. You can
use this as a custom function or just put it into the calc definition
of the field, if you use it only once in your db.
--
Lynn Allen
--
www.semiotics.com
Member FBA
FM 10 Certified Developer

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.