Search code examples
lotus-noteslotusscriptlotus

Lotus script Lockout users how to get list of useres in memo


    Sub Initialize

On Error GoTo e
Dim session As New NotesSession, db As NotesDatabase, view As NotesView
Dim nvec As NotesViewEntryCollection
Dim c As integer
Set db = session.currentdatabase

Set view = db.getView("Locked Out Users")
Set nvec = view.Allentries

c = nvec.count

If c > 0 Then

Call nvec.Removeall(true)

' Send notification
Dim sarr(1) As String
sarr(0) = "[email protected]"
sarr(1) = "[email protected]"

Dim mdoc As NotesDocument, rt As notesrichtextitem
Set mdoc = db.createdocument
mdoc.Form = "Memo"
mdoc.Subject = "Removed " + CStr(c) + " Locked out users on mypage"
Set rt = mdoc.Createrichtextitem("Body")
Call rt.Appendtext("Removed " + CStr(c) + " Locked out users")
Call rt.Addnewline(1) 
Call rt.Appendtext("Click to open lockout database")
Call rt.Appenddoclink(db,"Lockout")
Call mdoc.Send(False, sarr)

End If
Exit Sub
e:
Print Error,erl
End Sub

It's possible to get list of users who locked in memo (e-mail)? maybe there is a method to display and send this type of view in lotusscript?

It try

Dim item As NotesItem

Set item = doc.getItemValue("ILUserName")

each time he receives only their number


Solution

  • You need to put the nvec.Removeall to the end of your code as it deletes all locked out users.

    Then initialize your richtext and cycle through the collection and put each name in the richtext like that:

    Dim ve as NotesViewEntry
    Dim doc as NotesDocument
    
    …
    
    Call rt.Appendtext("Removed " + CStr(c) + " Locked out users")
    Call rt.Addnewline(1)
    Call rt.Appendtext("Removed the following users:")
    Call rt.Addnewline(1)
    view.AutoUpdate = False 'necessary in case a user is locked while the code runs then your reference migth become broken...
    Set ve = nvec.GetFirstEntry()
    While not ve is Nothing
      If ve.IsDocument then
        Set doc = ve.Document
        Call rt.AppendText( doc.IlUserName(0) )
        Call rt.Addnewline(1)
      End If
      Set ve = nvec.GetNextEntry( ve )
    Wend
    Call nvec.RemoveAll(True)
    …
    ' the rest code with the database link comes here.