Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

prevent access to record if being viewed by another user


This topic is 4276 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi all

 

Is it possible to put together a "locking" script where the system will prevent a user from opening a record should another user be accessing/viewing it at that current time? A simple dialog box denying access and then exiting the script should do - but how would filemaker check to see if another user has the record open?

Posted

If the record is being Edited by another user it is already locked automatically. Not sure about another user simply viewing the record.

Posted

If the record is being Edited by another user it is already locked automatically. Not sure about another user simply viewing the record.

 

I didn't know this, but it makes sense. I'm still interested about how I could prompt the other user should they try to edit the same record that another user is modifying. Possible?

Posted

it's very easy to test / simulate this.  Pick a record and start editing it (type some text in a field), leave the cursor in that field so that you do not commit.  Now from the Window menu open a new window.  That will open on the same record.  Try to edit the record in the new window.  You will see how FM handles a record lock

Posted

A quick Google search tells me that the error code returned for a "locked" record is 300. I want to create my own custom error message that fits the theme of the system I have written. How would I incorporate a script that returns my error message rather than the standard FM one? I would also like the message to display which user is using the locked record. I would prefer the record on the layout not even be accessible... if not, then perhaps have a field on the layout that states if the record is locked, and by which user. 

 

Is this possible? I would assume the get(lasterror) = 300 function would suffice. When the user clicks the "go to" button to access the record and layout, an IF statement could be run and check to see if the record is locked?

Posted

The script step Open Record/Request explicitly attempts to obtain the record lock. If you try this and receive an error, then either the record is in use or the user does not have the necessary edit privileges for this record. Therefore, you could write your own error message using a Custom Dialog.

 

However, I am not aware of any way to capture the "other" user name when attempting to edit a locked record. It's definitely on my wish list.

Posted

I didn't know this, but it makes sense. I'm still interested about how I could prompt the other user should they try to edit the same record that another user is modifying. Possible?

Yes.

 

This thread has become both convoluted and confused.  First, please go back an read what Wim said.

 

Second, the Error Code for a record Lock is 301, not 300.  If Google said that, it's wrong again.  300 is a file lock, something very different.

 

The original idea as I understood it was to alert a user going to a particular record that someone else was editing the record and for that first user not to try to do the same.  If the first user does try, FileMaker will return a default error message.

 

However, you can use the OnRecordLoad event trigger to run a script that checks the lock state of the record and returns a custom dialog advising the user with whatever message you desire. This will fire when the user loads the record. 

 

Steven

Posted

Hi all

 

First, thanks for your patience and help.

 

Currently, on the Layout Setup panel, under script triggers, I have OnRecordLoad run the following script:

 

Freeze Window

If [Get(LastError) = 301

Show Custom Dialog ["Incrementing lock has failed! The record is probably in use by another user."]

End If

Go to layout [original layout]

 

however, when I run Wim's test, an error isn't captured and I am still allowed to open the record (though FM does still prompt me if I do try to edit the content) even if I do return to the original layout (within the new window) and attempt to access the record again.

 

I have attempted to trigger this script via the OnLayoutEnter script trigger, and to no prevail. Also, I have tried to capture error 304 (layout in use by another user) and it doesn't work either. I'm assuming my script can't be set up correctly?

 

Many thanks again!

Posted

I believe you are missing a Set Error Capture [ON] step at the first of the script.  And then you have to do something to force the error such as setting a field to itself.  That will, of course, lock the record if it isn't already locked.

 

Steven

Posted

I believe you are missing a Set Error Capture [ON] step at the first of the script.  And then you have to do something to force the error such as setting a field to itself.  That will, of course, lock the record if it isn't already locked.

 

Steven

 

Thank you, Steven.

 

Can you provide an example of forcing the error by setting a field to itself? I'm a little confused by what you mean.

 

@brian rich - will check that out now!

 

Cheers

This topic is 4276 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.