Q
Problem solve Get help with specific problems with your technologies, process and projects.

Update 3-server connection records with one click

Hello, Here's a looping question that's probably easy but I'm still a bit new to LotusScript. I've developed a button that I send out to end-users that updates server connection documents in their personal address books. (They have DNS problems, thus the need for connection docs) There are three servers IP addresses that need to be updated. Currently, when users receive the button, they must click the button 3 times to get each record to update. I'd like the script to update all 3-server connection records with just one click. Any ideas?
Below is an excerpt from the script:

       Dim db As Notesdatabase
	
	Dim view As NotesView
	Dim doc As NotesDocument
	
	
	Set db = New Notesdatabase ("", "names.nsf")
	Set view = db.getview("AdvancedConnections") 
	Set doc = view.getfirstdocument() 
'for all the documents in the view 
	While Not (doc Is Nothing)
		
		If Trim(doc.Destination (0)) = "CN=Server1/OU=Acme1/O=Acme" Then
			
			Call doc.replaceitemvalue( "OptionalNetworkaddress", "10.208.0.40")
			Call doc.replaceitemvalue("PhoneNumber", "10.208.0.40")
			Call doc.save (True, True)
			Set doc = view.getnextdocument(doc)
		End If	
		If Trim(doc.Destination (0)) = "CN=Server2/OU=Acme1/O=Acme" Then
			
			Call doc.replaceitemvalue( "OptionalNetworkaddress", "10.208.96.40")
			Call doc.replaceitemvalue("PhoneNumber", "10.208.96.40")
			Call doc.save (True,True)
		End If
		If Trim(doc.Destination (0)) = "CN=Server3/OU=Acme1/O=Acme" Then
			Call doc.replaceitemvalue( "OptionalNetworkaddress", "10.208.16.40")
			Call doc.replaceitemvalue("PhoneNumber", "10.208.16.40")
			Call doc.save (True,True)
		End If
		'End If
		
'Go to the next document
		Set doc = view.getnextdocument(doc)
		
	Wend
	
	Messagebox "Connection Documents updated", 0, "Update Info"
				'If nooffice = "0" Then
				'	Messagebox "you don't have an office location document"
				'End If
End Sub

Try this trick for working with a loose collection - build a "List" and loop through its contents - so the list controls the loop, not the collection of connection documents. Use the following code as a starting point:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim DestList List As String

DestList("Server1/Acme1/Acme") = "10.208.0.40"
DestList("Server2/Acme1/Acme") = "10.208.96.40"
DestList("Server3/Acme1/Acme") = "10.208.16.40"

Set db = session.GetDatabase("", "names.nsf", False)
Set view = db.GetView("AdvancedConnections") 
ForAll svr In DestList
	Set doc = view.GetDocumentByKey(ListTag(svr))
	If (doc Is Nothing) Then
		Set doc = db.CreateDocument
		Doc.Form = "Connection"
		Doc.Destination = ListTag(svr)
	End If
	doc.OptionalNetworkaddress = svr
	doc.PhoneNumber = svr
	doc.ComputeWithForm(False)
	Call doc.save (True, True)
End ForAll

Dig Deeper on Domino Resources - Part 7

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close