我需要编写代码,以便在同一内部域中的最近联系人视图中查找重复条目。我不打算接触外部互联网联系人。是否有任何特殊的属性或方法(在Lotus脚本中?)将所有视图条目与服务器nab进行比较是个好主意?任何人都可以建议我这样做的最好方法吗?
答案 0 :(得分:1)
不确定我是否完全得到你需要的东西,但这是我的建议
我建议编写一小段代码,通过视图(最近的联系人)来创建一个列表并在那里只放置一对唯一的密钥/ doc并存储在另一个地方所有重复项。
您可以使用此类代码创建代理(请注意,我可能使用错误的密钥,因此只需为您定义哪个字段是唯一密钥)即
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个联系人的所有邮件域(最近的联系人)
答案 1 :(得分:0)
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() 退出子 结束子