Prevent doc editing based on field value

Two steps to prevent users from editing a doc if a field contains a specific value. (Queryopen & Querymodechange)
LotusScript


Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
     
     Dim doc As NotesDocument
     Set doc = Source.Document  
     
     If source.isnewdoc = False Then
          Dim fval As String
          fval = doc.fieldname(0)
     
          If fval = "fieldvalue" Then
               If source.EditMode = True Then
                    Messagebox "You cannot edit this document due to field value.", 16, "Edit Attempt Error"
                    continue=False
               End If          
          End If    
     End If    
     
End Sub


Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
     
     Dim doc As NotesDocument
     Set doc = Source.Document  

     Dim fval As String
     fval = doc.fieldname(0)
     
     If fval = "fieldvalue" Then
          continue = False
          Messagebox "You cannot edit this document due to field value.", 16, "Edit Attempt Error"
     End If
     
End Sub

Posted by fbrefere001 on Thursday April 26, 2001