Link to home
Start Free TrialLog in
Avatar of Peripheal
Peripheal

asked on

Cause of a checkbox field to disappear with a backend save call?

I have a piece of code in the QueryOpen of a document which works in the backend of the doc and calls a back end save.  When this code is in place, the one checkbox field I have the form totally disappears.  This same piece of code works well in another form with a checkbox field in it.  The form properties are the same with the exception of the non-working form has 'Formulas inherit values from selected document'.  But there is no formula in the Lock field.  Here is the code:

     'If doc is new document then exit sub
     If (Source.IsNewDoc) Then
          Exit Sub
     End If   'New Doc, Lock not reqd
     
     Dim varLock As Variant
     Dim session As New NotesSession
     Dim nnUserName As New NotesName(session.UserName)
     
     'Grab the backend document to do the work there
     Set docBackend=Source.document
     
     'Get the lock field
     varLock=docBackend.GetItemValue("Lock")
     
     'If lock field is not empty - put up message
     If (varLock(0) <> "") Then
          Msgbox ("Document is currently locked by "+varLock(0)+". A read-only copy will be opened for your use.")
          Exit Sub
     End If
     
     'put current user name in lock field to keep doc locked until done editing.
     docBackend.Lock=nnUserName.Common
     Call docBackend.Save(True,True)
     

The last line is the culprit which makes the checkbox field disappear.  Any insight is greatly appreciated!
Avatar of HemanthaKumar
HemanthaKumar

Is this Lock field checkbox ? If so what is the formula for choices ? If you are pointing to a field, check if this is inherited properly.

~Hemanth
Avatar of Zvonko
Put into Lock field default value this formula:
Lock

Please be aware that the name of the field has to be without quotas.

Good luck,
Zvonko
ASKER CERTIFIED SOLUTION
Avatar of scottrma
scottrma

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
Avatar of Peripheal

ASKER

Scott,

Thank you for the information.  Another one of those wonderful features of Notes!  I just added a default value in the checkbox field to make it work.  That's not what I wanted to do, but I can live with it.

I appreciate your time!

Have a great weekend!
Lisa
Hi Lisa,

Glad to hear you were able to use a workaround. Believe me, I have seen Notes do much weirder things than this :-)

Have a great weekend as well.

Regards,

Scott