I need to know if anyone can help. I need to change a value in a group of users connection documents in their local address books, in this case an ip addresss. Does anyony have any script that they are willing to share? Thanks.
Subject: Automatically changing a connection document via a script?
Put this in a button or other UI action;
Sub Click(Source As Button)
' agent to loop through all location documents in local address book and set domain field to "XYZ"
' local address book must be named names.nsf
Dim session As New NotesSession
Dim db As New NotesDatabase("","names.nsf")
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim i As Integer
Set dc = db.AllDocuments
On Error Goto ErrorHandler
For i = 1 To dc.Count
Set doc = dc.GetNthDocument(i)
If(doc.Form(0) = "Location") Then
Call doc.ReplaceItemValue("Domain","XYZ")
Call doc.Save(True,False)
End If
Next
Msgbox "Location update complete", "0" , "Success!"
Exit Sub
ErrorHandler:
Msgbox "Domain name was NOT updated. Please submit a ticket to IS_Problems stating that the Location Domain change failed.", "0", "Failed"
End
End Sub
Subject: variation …Automatically changing a connection document via a script?
This obviously originated from the same source but has extra code. It has been in my formula library database for 5 years. I have not used it lately but it looks like it should work. It can be adapted to do the fieldsyou need changed.
This example reads a user’s addressbook and updates location docs. Good examples of error checking, etc.
Declarations Event
’ System variables → DO NOT CHANGE!!!
Const VIEW_LOCATION_NAME = “($Locations)”
Const VIEW_CONNECTION_NAME = “($Connections)”
'Application variables → EDIT THESE ONES!!!
Const OLD_DOMAIN_NAME = “XYZ” ’ This is the value of your old domain
Const NEW_DOMAIN_NAME = “Acme” ’ This is the value of your new domain
Click Event
Dim session As New NotesSession
Dim dbNab As NotesDatabase
Dim view As NotesView
Dim note As NotesDocument
Dim sNamesLine As String
Dim nPos As Integer
Dim sDomainValue As String
Dim bNeedsUpdate As Integer
Dim bLocationModified As Integer
On Error Resume Next
’ first, get the local NAB
sNamesLine = session.GetEnvironmentValue(“names”,True)
nPos = Instr(sNamesLine, “,”)
If nPos > 0 Then
sNamesLine = Left$(sNamesLine, nPos-1)
Else
sNamesLine = “names.nsf”
End If
Set dbNab = New NotesDatabase( “”,sNamesLine )
If Not(dbNab.isOpen) Then
Messagebox(“Could not locate your Name & Address book.”)
Exit Sub
End If
’ update all location documents
Set view = dbNab.GetView(VIEW_LOCATION_NAME)
If (view Is Nothing) Then
Messagebox("Your Name & Address book is missing a
required view.")
Exit Sub
End If
Set note = view.GetFirstDocument
While Not(note Is Nothing)
sDomainValue = note.Domain(0)
If Lcase(sDomainValue) = Lcase(OLD_DOMAIN_NAME) Then
note.Domain = NEW_DOMAIN_NAME
Call note.save(True,False)
bLocationModified = True
End If
Set note = view.GetNextDocument(note)
Wend
If (bLocationModified) Then Messagebox("You need to restart
Notes in order for these changes to take place.")
’ update all connection documents
Set view = dbNab.GetView(VIEW_CONNECTION_NAME)
If (view Is Nothing) Then
Messagebox("Your Name & Address book is missing a
required view.")
Exit Sub
End If
Set note = view.GetFirstDocument
While Not(note Is Nothing)
bNeedsUpdate = False
sDomainValue = note.SourceDomain(0)
If Lcase(sDomainValue) = Lcase(OLD_DOMAIN_NAME) Then
note.SourceDomain = NEW_DOMAIN_NAME
bNeedsUpdate = True
End If
sDomainValue = note.DestinationDomain(0)
If Lcase(sDomainValue) = Lcase(OLD_DOMAIN_NAME) Then
note.SourceDomain = NEW_DOMAIN_NAME
bNeedsUpdate = True
End If
If (bNeedsUpdate) Then Call note.save(True, False)
Set note = view.GetNextDocument(note)
Wend