0

我需要编写代码以在同一内部域内的最近联系人视图中查找重复条目。我不会接触外部互联网联系人。是否有任何特殊的属性或方法(在 Lotus 脚本中?)将所有视图条目与服务器 nab 进行比较是个好主意?谁能建议我最好的方法来做到这一点?

4

2 回答 2

1

不确定我是否完全满足您的需求,但这是我的建议

我建议编写一小段代码,通过视图(最近的联系人)并创建一个列表,然后只放一对唯一的密钥/文档并将所有重复项存储在另一个地方。

你可以用这样的代码创建一个代理(请注意,我可能使用了错误的键,所以只需定义你的哪个字段是唯一键)即

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 个联系人的所有邮件域(最近的联系人)

于 2012-10-26T07:14:37.393 回答
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 Error() & " " & Erl() Exit sub End Sub

于 2012-10-26T10:18:13.297 回答