我需要编写代码以在同一内部域内的最新联系视图中查找重复条目。我不会触摸外部互联网联系人。将所有视图条目与服务器NAB进行比较的特殊属性或方法是好主意吗?谁能建议我最好的方法?
不确定我是否完全得到您需要的东西,但这是我建议的
我建议编写一小串通过查看(最近的联系人)行走的代码,并创建一个列表,并将其放在一个唯一的键/文档,然后存储在另一个地方。
您可以使用此类代码创建一个代理(请注意,我可能会使用错误的密钥,因此只需定义哪个字段是唯一键)即
Dim session As New NotesSession
Dim view As NotesView
Dim doc As NotesDocument
Dim uniquedocs List As Variant
Dim duplicates As string
Dim key As String
Set view = session.Currentdatabase.Getview("(Recent Contacts)")
Set doc = view.Getfirstdocument()
While Not doc Is Nothing
' this is the unique key, please change it if you need
key = doc.Getitemvalue("MailDomain")(0)
If key <> "" Then
If Not IsElement(uniquedocs(key)) Then
Set uniquedocs(key) = doc
Else
If duplicates <> "" Then duplicates = duplicates & " | "
duplicates = duplicates & key
End If
End If
Set doc = view.Getnextdocument(doc)
Wend
MsgBox duplicates
重复 - 是一个字符串,其中所有邮件域至少有2个联系人(最近的联系人)
Sub Initialize
On Error GoTo errHandler
Dim session As New NotesSession
Dim db As NotesDatabase
Dim currdb As NotesDatabase
Dim view As NotesView
Dim view1 As NotesView
Dim vc As NotesViewEntryCollection
Dim namesentry As NotesViewEntry
Dim serdoc As NotesDocument
Dim localdoc As NotesDocument
Dim item As NotesItem
Dim dname As String
Dim serverfullName() As String
Dim localfulName As String
Dim formula As String
Dim result As Variant
Dim count As Integer
'Getting all the documents from servers NAB ,put that in document collection
Set db=session.GetDatabase("Myserver","names.nsf")
Set view=db.GetView("People")
Set vc = view.AllEntries
Set namesentry = vc.Getfirstentry()
ReDim Serverfullname(CInt(vc.Count))
count = 0
'storing fullnames in array
While Not namesentry Is Nothing
Set serdoc = namesentry.Document
serverfullName(count) = serdoc.Getitemvalue("FullName")(0)
Set namesentry = vc.Getnextentry(namesentry)
count = count + 1
Wend
'keeping the string format for Comparison
Dim x As String
Dim iteration As Integer
x = ""
iteration = 0
ForAll i In Serverfullname
iteration = iteration + 1
If i ="" Then
ElseIf count = iteration Then
x = x + |"| + i + |"|
Else
x = x + |"| + i + |"| + ":"
End If
End ForAll
'MsgBox x 'Displaying servers fullname list
'Geetting local NAB contacts
Set currdb= session.CurrentDatabase
Dim selFormula As String
'creating New view to filter documents with same domain
selFormula= {SELECT @UpperCase($AutoCreatedList) = "DIP" & @LowerCase(MailDomain)=@LowerCase("mydomain")}
Call currdb.Createview("RecentView",selFormula)
Set view1 = currdb.GetView("RecentView")
Set localdoc = view1.GetFirstDocument
While Not localdoc Is Nothing
localfulName = localdoc.Getitemvalue("FullName")(0)
Dim indexresult As Variant
Dim Formula1 As String
Formula1 = |@Contains(| & x & |;"| + Localfulname + |")|
'MsgBox Formula1
indexresult = Evaluate(Formula1)
If indexresult(0)= 0 Then
MsgBox " Duplicate entry " & localfulname & "."
'Call localdoc.Remove(true)
End If
Set localdoc = view1.Getnextdocument(localdoc)
Wend
Exit sub
errhandler: msgbox错误()&amp;"&amp;erl() 出口子结束子