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!
LVL 11
Andrew AngellCo-Owner / DeveloperAsked:
Who is Participating?
 
lesouefCommented:
easier: Get ( RecordOpenState )
0
 
JoJohn2004Commented:
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.
0
 
Andrew AngellCo-Owner / DeveloperAuthor Commented:
Sounds good.  I'll play with that and get back to ya.  Thanks!
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Andrew AngellCo-Owner / DeveloperAuthor Commented:
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.
0
 
JoJohn2004Commented:
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.
0
 
Andrew AngellCo-Owner / DeveloperAuthor Commented:
Yes, I discovered this but I had already awarded the points.  Sorry about that.  I should have waited until I actually got it working.  :(
0
 
lesouefCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.