Link to home
Start Free TrialLog in
Avatar of Andrew Angell
Andrew AngellFlag for United States of America

asked on

Is there a way to check if another user is currently in the record priot to running a script?

Is there a function or something I can use to check if a record is locked prior to running a script?  For example, I have a script setup to charge credit cards from data in FileMaker.  You push a button in the Invoice layout and it charges the card and returns data into FM via ODBC.

The problem is that if somebody else is in the record when you run the card you end up with a SQL error because the record is locked by another user.  I'd like to be able to check this immediately upon the button being pushed so that if the record is locked it will display a custom diag. and allow them to run it later when the other person is out of the record instead of running the card but not being able to return data.

I can't seem to find any functions for this.  Any info. would be greatly appreciated.  Thanks!
Avatar of JoJohn2004
JoJohn2004

The Get ( LastError ) = 301 statement can be used for this. At the beginning of the script, go to any field in the record about to be changed. Attempt to change a field by, for example, using a set field to set it to itself. If there is someone already in this record an error code of 301 will be returned. Use the Set Error Capture script step along with an if statement to test for this error and branch accordingly.
Avatar of Andrew Angell

ASKER

Sounds good.  I'll play with that and get back to ya.  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Member_2_908359
Member_2_908359
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ah, nice.  I was hoping there was something like that available.  I hadn't gotten a chance to play yet.  I'll come back and update when I do...it won't be long.
Just a note about this. Although I have not tried it myself, Get(RecordOpenState) only works on the user's current session. It will not check the network. If you want to get the status of the network, you have to use the script step Open  Record/Request and then test for an error. At least that is what it says in Filemaker 9 Developers Desk Reference.
Yes, I discovered this but I had already awarded the points.  Sorry about that.  I should have waited until I actually got it working.  :(
sorry, no server here to check this...
you can ask for a refund or change for JJ , no pb for me.
BTW, I have to check, but there should be a SQL command to check the record status, but I am not sure in which SQL brand I saw this, maybe not mySql