Hot Topic (More than 10 Replies) Multi-User Locking (Read 1541 times)
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Multi-User Locking
Feb 17th, 2008 at 11:05pm
Print Post Print Post  
(Cross posted to Sesame Online Support)

I'd like some more information on multi-user locking, as it's causing me a big headache.  On my form, I do a number of lookups in the On Form Load event.  For reasons I have yet to determine, these lookups fail to function when accessing a record that is current locked by another user (either the lookups fail or the locking disallows the form fields to be programatically populated).  The problem is that I do writes using XResultSetValue during the On Form Exit event.  Some of the writes utilize data that was supposed to have been loaded in the On Form Load event.  Since the data failed to load, the writes I have in On Form Exit effectively overwrite my data with empty data.  Very very bad.

One workaround I tried was to check the locked status of the form's result set.  Unfortunately, there was no consistency in the locked status.  Sometime it would say the form was locked, and sometime unlocked, with no consistent pattern.  The code I used to check the locked status in the On Form Load event was:

Code
Select All
If @XResultSetLocked( @XResultSetCurrentForm() ) = 0 Then
	WriteLn( "Locked Status = Not Locked" )
Else
	WriteLn( "Locked Status = Locked" ) 


I don't care if my lookups fail, as long as I have some mechanism to use to know to turn off my code in the On Form Exit event.  I'd prefer that my lookups succeed, but right now it is much more important that my data doesn't get blown away.  Unfortunately, this whole situation is difficult to test, since it can't be tested using the Designer's Preview mode.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Multi-User Locking
Reply #1 - Feb 18th, 2008 at 1:23am
Print Post Print Post  
When you say "On Form Load" do you mean On Form Entry or GLOBAL CODE?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Multi-User Locking
Reply #2 - Feb 18th, 2008 at 1:25am
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 1:23am:
When you say "On Form Load" do you mean On Form Entry or GLOBAL CODE?

Sorry.  On Form Entry.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Multi-User Locking
Reply #3 - Feb 18th, 2008 at 2:18am
Print Post Print Post  
Lookups will return data from a locked record, so the problem must be the record to which you are trying to write. Can I see the code for what you are doing with the data you get back from the lookups?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Multi-User Locking
Reply #4 - Feb 18th, 2008 at 2:59am
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 2:18am:
Lookups will return data from a locked record, so the problem must be the record to which you are trying to write. Can I see the code for what you are doing with the data you get back from the lookups?

I tested further and confirmed that it's not the lookups that are failing but the fields that are being disallowed from being populated.  Here's a relevant code fragment from my On Form Entry event:

Code
Select All
txtZip = @XResultSetValue(vintResultSetIn, "fZip")
WriteLn( "Zip from database: " + @XResultSetValue(vintResultSetIn, "fZip"))
WriteLn( "Zip in document: " + txtZip ) 



That produces the following output:

Zip from database: 99999
Zip in document:

Note again that this only occurs when the form is locked due to a multi-user issue.  It works fine otherwise.
  
Back to top
 
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Multi-User Locking
Reply #5 - Feb 18th, 2008 at 12:26pm
Print Post Print Post  
BTW, I should have mentioned that the fields I'm trying to set are unbound fields.  A workaround to this problem is to simply try setting an unbound field to a value (any value) during On Form Entry.  Immediately after setting the field, run an @IsBlank check.  If the field is still blank, the form is locked.  Here's an example:

Code
Select All
txtUnboundValue = "LOCKED"
If @IsBlank( txtUnboundValue ) Then WriteLn( "Unbound value is Blank - Form Locked" ) 



Unfortunately, with workarounds like this, they may fail to work in the future if Sesame changes how the form reacts to a multi-user lock.  Thus, I'd still like to see an official mechanism for recognizing a multi-user lock, or a fix which allows unbound fields to be populated even under a multi-user lock.  I'd prefer both, as I'd like to both load a locked form with data and suppress the validation/save logic in On Form Exit when the form has a multi-user lock.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Multi-User Locking
Reply #6 - Feb 18th, 2008 at 12:29pm
Print Post Print Post  
Do you have elements on this form which are bound?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Multi-User Locking
Reply #7 - Feb 18th, 2008 at 12:35pm
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 12:29pm:
Do you have elements on this form which are bound?

Many.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Multi-User Locking
Reply #8 - Feb 18th, 2008 at 1:03pm
Print Post Print Post  
OK. We'll see about a @Locked function of some sort.  Meanwhile, people usually do this by checking the read only state of a bound element that is not usually read-only. If it is read-only, then the record is locked.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Multi-User Locking
Reply #9 - Feb 18th, 2008 at 2:09pm
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 1:03pm:
Meanwhile, people usually do this by checking the read only state of a bound element that is not usually read-only. If it is read-only, then the record is locked.

That logic doesn't appear to work cleanly, because the test field isn't reset to writable before the On Form Entry event when navigating from a locked record to an unlocked record.  This may be because I'm manually setting the field to Read Only (along with a lot of other state changes) after determining the record is locked (I do this because I have my own record locking scheme that's independent of the multi-user case).  I'm falling back to my workaround for now.

A new "@Locked" method and the ability to set unbound fields in a multi-user locked record would definitely be welcome.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Multi-User Locking
Reply #10 - Feb 18th, 2008 at 2:15pm
Print Post Print Post  
MP wrote on Feb 18th, 2008 at 2:09pm:
Hammer wrote on Feb 18th, 2008 at 1:03pm:
Meanwhile, people usually do this by checking the read only state of a bound element that is not usually read-only. If it is read-only, then the record is locked.

That logic doesn't appear to work cleanly, because the test field isn't reset to writable before the On Form Entry event when navigating from a locked record to an unlocked record.  This may be because I'm manually setting the field to Read Only (along with a lot of other state changes) after determining the record is locked (I do this because I have my own record locking scheme that's independent of the multi-user case).  I'm falling back to my workaround for now.

Your workaround sounds fine. You may also want to check On Form Exit before you do the action that is causing the problem.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged