I got this script from someone. I have this in the mail template in the post open. What I’m trying to accomplish is create one connection document. However, it doesn’t seem to be working right. It creates the same connection document every time the mail file is opened – so I now have about 20 of the same connection docs. How do I modify it so it checks for that particular connection doc. and if it doesn’t exist, it creates, if not it won’t create?Thanks in advance
Helen
Function setcon
Dim session As New NotesSession
Dim Username As New NotesName(session.UserName)
Dim empdb As New NotesDatabase("","names.nsf")
Dim conndoc As New NotesDocument(empdb)
Dim targetdb As New NotesDatabase("", "")
Dim dc As NotesDocumentCollection
Set dc = empdb.Search({(Form = "Connection" | Form = "local") & @UpperCase(@Name([Abbreviate];Destination)) = "MAILWEB1/XX/XX/US"},Nothing,0)
If dc.count = 0 Then
Set conndoc = New Notesdocument(empdb)
conndoc.form = "Connection"
conndoc.ConnectionType = "0"
conndoc.Destination = "CN=MAILWEB1/OU=XX/O=XX/C=US"
conndoc.LanPortName = "TCPIP"
conndoc.PortName = "TCPIP"
conndoc.ConnectionLocation = "*"
conndoc.OptionalNetworkAddress = "mailweb1.xxx.com"
conndoc.PhoneNumber = "mailweb1.xxx.com"
conndoc.ConnectionLocation = "*"
conndoc.Type = "Connection"
conndoc.Source="*"
conndoc.ConnectionRecordFirst = "1"
conndoc.ComputeWithForm False,False
Call conndoc.Save( True, True )
Else
Set conndoc = dc.GetFirstDocument
conndoc.ConnectionRecordFirst = "1"
conndoc.Destination = "CN=MAILWEB1/OU=XX/O=XX/C=US"
conndoc.ComputeWithForm False,False
Call conndoc.Save( True, True )
End If
End Function