'"Name not found in the directory please use catalog to choose names" Lotus notes error
I'm getting the error when I pick one of the name which is in the domino directory. All of them who pick the particular name get the same error only for that name.
I have checked with the administrator as well, there is no issue with the name of the person and I don't see any issue with lotus script code also. Please help me to know what's wrong with the code.
Please find the below code.
Dim doc As NotesDocument, maildocCC As NotesDocument, maildoc As NotesDocument, docPerson As NotesDocument
Dim dc As NotesDocumentCollection
Dim db As NotesDataBase, dbusers As NotesDataBase
Dim w As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim viewPerson As NotesView
Dim body As NotesRichtextItem
Dim solicitante As NotesName, nam As NotesName, nomeAprovador As NotesName, revisor As NotesName
Dim i As Integer, x As Integer, u As Integer, z As Integer, qtdRevisores As Integer
Dim aprovadores As Variant, informativo As Variant, listaRevisores As Variant
Dim nomesInf As String, nome As String, revisores As String, firstName As String, middleName As String, lastName As String
Dim nomesIncorretos As String, nomePerson As String
Dim nomeIncorreto As Boolean
Set db=session.CurrentDatabase
Set uidoc = w.CurrentDocument
Set doc=uidoc.document
'Validar
If doc.addReviewer(0)="" Then
Msgbox "Please indicate to whom you want to send the analysis!",0+16,"Attention!"
Call uidoc.GotoField("addReviewer")
Exit Sub
End If
Set solicitante = session.CreateName(doc.solicitante(0))
aprovadores=doc.addReviewer
listaRevisores=doc.revisores
Forall c In aprovadores
Set nam = session.CreateName(c)
If nam.Abbreviated=solicitante.Abbreviated Then
Msgbox "The requester cannot be part of the reviewers list!",0+16,"Attention!"
Call uidoc.GotoField("addReviewer")
Exit Sub
End If
End Forall
Set dbusers = New NotesDatabase( db.Server , "names.nsf" )
If Not dbusers.IsOpen Then
Messagebox "Unable to open the directory of users!",0+16,"Attention!"
Exit Sub
End If
nomeIncorreto=False
nomesIncorretos="[ "
Forall a In aprovadores
Set nam = session.CreateName(a)
nome=nam.Common
If Instr(nam.Abbreviated)>0 Then
If Instr(nam.Abbreviated)>0 Then
nomeIncorreto=True
If nomesIncorretos="[ " Then
nomesIncorretos=nomesIncorretos + a
Else
nomesIncorretos=nomesIncorretos + ", " + a
End If
Else
Set viewPerson= dbusers.GetView("($Users)")
Set dc = viewPerson.GetAllDocumentsByKey(Lcase(nome), False)
Set docPerson = dc.GetFirstDocument
If docPerson Is Nothing Then
Msgbox "The name '"+nome+"' was not found in the address book! Please use the notes catalog to select the user!",0+16,"Attention!"
Call uidoc.GotoField("addReviewer")
Exit Sub
Else
While Not docPerson Is Nothing
firstName=docPerson.FirstName(0)
middleName=docPerson.MiddleInitial(0)
lastName=docPerson.LastName(0)
If middleName="" Then
nomePerson=firstName+" "+lastName
Else
nomePerson=firstName+" "+middleName+" "+lastName
End If
If nome<>nomePerson Then
nomeIncorreto=True
If nomesIncorretos="[ " Then
nomesIncorretos=nomesIncorretos + nome
Else
nomesIncorretos=nomesIncorretos + ", " + nome
End If
End If
Set docPerson = dc.GetNextDocument(docPerson)
Wend
End If
End If
Else
nomeIncorreto=True
If nomesIncorretos="[ " Then
nomesIncorretos=nomesIncorretos + a
Else
nomesIncorretos=nomesIncorretos + ", " + a
End If
End If
End Forall
If nomeIncorreto Then
Msgbox "The names "+nomesIncorretos+" ] were not found in the address book! Please use the notes catalog to select the users!",0+16,"Attention!"
Call uidoc.GotoField("addReviewer")
Exit Sub
End If
doc.reviewerList=Arrayunique(Arrayappend(doc.reviewerList,aprovadores))
doc.revisores=Arrayunique(Arrayappend(doc.revisores,aprovadores))
Forall e In aprovadores
i=i+1
Set nam = session.CreateName(e)
nome=nam.Abbreviated
If i>1 Then
revisores=revisores + ", " + nome
Else
revisores=nome
End If
End Forall
Call uidoc.Close
Solution 1:[1]
I see several issues with your code, and I hope one of them is the culprit.
- You have two identical lines testing
Instr(), so one of theelseparts is never executed. - As far as I know,
Instr()has 2 parameters. - For every aprovador you reopen the ($Users) view; it can be done only once
- You can test
dc.Count=0in order to find out if no documents are found. - I don’t understand why you’re using
CreateNameall the time; aren’t you sure about the formats of the values you have to compare? Aren’t all fields Names fields? - Why do you use
GetAllDocumentsByKeywith a 2nd parameter False? Don’t you want an exact match? - Otherwise, why don’t you use
GetDocumentByKeyto find the matching user? - Guessing: is the person whose name cannot be found the only one with a middle name?
That’s it for now…
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
