Delete server connection with Lotus script

I've a lotus script that deletes a server connection in the Lotus Notes Addressbook.
It works fine.
The only problem is that the script looks for the server name and not for the IP Address.
When I enter the IP Address the script doesn't find the server connection.
E.g.
there is below connections.
RMD01/SERVER/COMPANY     10.181.0.146
RMD01/SERVER/COMPANY     10.181.27.244
When the script runs it deletes both of them.
But I will that the second connection stays there because that's the new IP.
How to do it?

Sub Click(Source As Button)
      Dim s As New notessession
      Dim db As notesdatabase
      Dim doc As notesdocument
      Set db = s.GetDatabase( "", "names.nsf", False )
      If db Is Nothing Then
            Msgbox "Cannot find names.nsf!"
      Else
            Dim view As NotesView
            Set view = db.GetView( "Connections" )
            Set doc = view.GetDocumentByKey( "RMD01/SERVER/COMPANY" )
            If Not ( doc Is Nothing) Then
                  Msgbox "The connection was deleted successfully"
                  Call doc.Remove( True )
            Else
                  Msgbox "Cannot find the old server connection"
            End If
      End If
End Sub
verto33Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

madheeswarCommented:
can u ask in Community support to delete those IP address?

its always recommended NOT to publish server name and IP address.
ZvonkoSystems architectCommented:
Check this:

Sub Click(Source As Button)
     Dim s As New notessession
     Dim db As notesdatabase
     Dim doc As notesdocument
     Set db = s.GetDatabase( "", "names.nsf", False )
     If db Is Nothing Then
          Msgbox "Cannot find names.nsf!"
     Else
          Dim view As NotesView
          Set view = db.GetView( "Connections" )
          Set doc = view.GetDocumentByKey( "RMD01/SERVER/COMPANY" )
          If Not ( doc Is Nothing) Then
              If (doc.OptionalNetworkAddress(0)="10.181.27.244") Then
                  Call doc.Remove( True )
                  Msgbox "The connection was deleted successfully"
              End If
          End If
     End If
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
verto33Author Commented:
Thanks, it works.
But there are users who doesn't have the old server connection anymore therefore I want to add a message for that case.

Something like that:

Call doc.Remove( True )
                  Msgbox "The connection was deleted successfully"
Else
Msgbox "There is no old server connection to delete"

But it doesn't work.
 
ZvonkoSystems architectCommented:
Check this:


Sub Click(Source As Button)
     Dim s As New notessession
     Dim db As notesdatabase
     Dim doc As notesdocument
     Set db = s.GetDatabase( "", "names.nsf", False )
     If db Is Nothing Then
          Msgbox "Cannot find names.nsf!"
     Else
          Dim view As NotesView
          Dim found As Integer
          Set view = db.GetView( "Connections" )
          Set doc = view.GetDocumentByKey( "RMD01/SERVER/COMPANY" )
          If Not ( doc Is Nothing) Then
              If (doc.OptionalNetworkAddress(0)="10.181.27.244") Then
                  Call doc.Remove( True )
                  Msgbox "The connection was deleted successfully"
                  found = True
              End If
          End If
          If (Not Found) Then Msgbox "There is no old server connection to delete"
     End If
End Sub

verto33Author Commented:
With the addition

>> If (Not Found) Then Msgbox "There is no old server connection to delete"

the server connection won't be deleted what's more I get the message "There is no old server connection to delete"
although the server connection is in the Addressbook.

The first script is OK.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.