2012-10-25 66 views
0

我需要编写代码以查找同一内部域中近期联系人视图中的重复项。我不打算接触外部互联网联系人。是否有任何特殊的属性或方法来做到这一点(在莲花脚本?)比较所有视图条目与服务器NAB是好主意?任何人都可以建议我这样做的最佳方式?在最近的联系人视图中查找重复的联系人

回答

1

不知道如果我完全得到你所需要的,但这里是我建议

我建议写的小一串代码,通过视图(最近联系人)行走,并创建一个列表,并把那里只有唯一对/ key和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 

重复 - 与所有邮件串 MSGBOX错误()& “” & Erl的() 退出子 结束SU:具有鉴于至少2个触点(最近的联系人)

+0

让我很明确的告诉我的要求, 我需要从本地names.nsf中的所有条目,然后我需要每个文档(联系人)与服务器NAB比较,如果不存在我需要删除联系人或从本地names.nsf – Mythli

+0

文件我试过代码如下, 首先,我会从服务器NAB的“人”观统领全名称值,并将其存储在字符串数组。 这是做这件事的最好方法吗? 然后我会得到所有条目从本地NAB, 然后内部循环,我将全名各个接点(在最近联系人视图)与全名 的服务器阵列,如果它返回false,这是重复的,所以我会从删除比较当地人。 – Mythli

+0

是的,你写的是正确的方式,我会做同样的,你写的。 –

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)[email protected]("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域b

相关问题