Hi, in my notes address Person view, I want to search a document based on a user’s name’s full name. If this user existed, then I do something, otherwise, I do another thing.Since I do not want to change current view which has LastName, First in first column, how to write Lotus Script code to search efficiently?
For I get notes document collection, and loop from first document, then read document one by one, If I found a name by using instr(“”,“”) function, then I do first thing, but the problem is how to identify if a name is not existed? I need to search the entire documents in that view and then I can know that user is not existed, currently I am thinking to get the number of collection, if the loop times equals the number of collection, and not name match, then I can know that user does not existed,
The fastest way to lop through a view is to get a NotesViewEntryCollection object and then loop through that one using GetFirstEntry and GetNextEntry. You then use the ColumnVlaues property to get the values from the column(s) where you want to check the values.
If you want to see if a particular name is not in the view, I would create a list, with teh name as the list tag. You can then use IsElement() to check if the specified name is in the list or not.
Something like this (incomplete/untested code):
Dim username List As Boolean
Dim col as NotesViewEntryCollection
Dim entry as NotesViewEntry
Set col = view.AllEntries
Set entry = col.GetFirstEntry
Do Until entry Is Nothing
'*** Get lastname, first name
tmpname = entry.ColumnValues(0)
'*** Add code here to swap name into firstname lastname
'*** if needed for later
username(tmpname) = True
Set entry = col.GetNextEntry(entry)
Loop
You now have a list of names that are in the first column of the view. Now you can do your comparisons.
Hi Karl, thanks for your quick response,There are many ways to loop the view documents, notesviewcollection oject is one way for sure, but
you may misunderstood my question, or I comfused you…
to make it simple, how can I know the record is not existed in all documents in that view? theoritically, I need to loop all records , if nothing match, then I can conclude the record is not exited, right? should I check if I have looped all documents based on the numbers of documents?