Domino Code Fragment

Code Name*
Who can edit a field is determined by reading a group of users from view and comparing them to the current user
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.149.233.72
Description*
Upon entering a field, a view is read to determine if the person can edit that field. The view that is read is created from a form that has the key eEngine value and the persons in the aTest_Eng (test engineers) field.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
It will boot the person out if no engine was entered. See the P&W Engine Development Plans database
Files/Graphics attachments (if applicable): Code:
Sub Entering(Source As Field)
    Dim W As New NotesUIWorkspace       ' this script checks to see if an engine was entered. If it was it will determine
    Dim session As New NotesSession         ' if the user can edit this field by reading the z. Admin view and checking his name and role
    Dim db As NotesDatabase
    Dim view As notesview
    Dim UIDoc As NotesUIDocument
    Dim Doc As NotesDocument
    Dim dockey As notesdocument
    Dim rcview As Integer
    Dim Key As String
    Dim canedit  As String
    Dim CurrUser As String ' from an @name on form
    Dim i As Integer
    Set UIDoc = W.CurrentDocument
    Set doc = uidoc.document
    Set db = session.CurrentDatabase
    CurrUser = UIDoc.FieldGetText ("eUser")
    canedit = "no"
    Key = doc.eEngine(0)
    If key <> "" Then          ' 100
         Set view = db.GetView("z. Admin")
         rcview = view.FTSearch(Key,1)
         If (rcview = 1 ) Then      ' 200
              Set docKey = view.GetFirstDocument
              Forall x  In docKey.aTest_Eng

                    If Cstr(x) = CurrUser Then        ' 300
                        canedit = "yes"
                   End If                                      ' 300
              End Forall      
         End If              ' 200
         If canedit <> "yes" Then         ' 100
              Messagebox("You cannot edit this field")
              uidoc.gotofield("eComments")
              Call view.Clear
         End If                                       ' 100
    Else
         Messagebox("Please select an engine first")
         uidoc.gotofield("eComments")
    End If   ' 100
End Sub