How do I change the $Saved Addresses field on my domino server address book and for all clients address books?

The $Saved Addresses contains an invalid FQDN that I need to change in order for failover to work.
LVL 3
jvutechncAsked:
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.

jvutechncAuthor Commented:
I'm not changing my companies domain name so I don't see how that code will help.   The $SavedAddresses is used to to help the notes client locate a domino server.
0
mbonaciCommented:
Notice the word change in my comment.
The code I posted contains functions (which you don't have to change) GetLocationItem and SetLocationItem!

The field you want to change is located in "Location Documents", isn't it (both server and local NABs)? So I thought SetLocationItem could help ;)

You have a field $SavedServers (which you also may want to change).
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

mbonaciCommented:
Also, the request in the question I referred to wasn't to change domain name, but to change mail addresses in location docs.
0
LotusDaveCommented:
Rather than change them you can just dlete them and then they will get re-populated. Here's a couple of agents that you can use in buttons -

For the user -

Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim port As Variant
Set db=session.GetDatabase(",NAMES.NSF)
Set view=db.GetView(Locations)
Set doc=view.GetFirstDocument
While Not (doc Is Nothing)
Call doc.RemoveItem($SavedAddresses)
Call doc.RemoveItem($SavedPorts)
Call doc.RemoveItem($SavedServers)
Call doc.save(True,True)
Set doc=view.GetNextDocument(doc)
Wend
Messagebox(Removing Cached Addressed Completed)
End Sub

And for the Domino Directory -

Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim port As Variant
Dim whichserver As String
whichserver=Inputbox$(Which server?)
Set db=session.GetDatabase(whichserver,NAMES.NSF)
Set view=db.GetView(Locations)
Set doc=view.GetFirstDocument
While Not (doc Is Nothing)
Call doc.RemoveItem($SavedAddresses)
Call doc.RemoveItem($SavedPorts)
Call doc.RemoveItem($SavedServers)
Call doc.save(True,True)
Set doc=view.GetNextDocument(doc)
Wend
Messagebox(Removing Cached Addressed Completed)
End Sub

0
jvutechncAuthor Commented:
Thank you for the Agents!  I will use them later and will get back to you.
0
Sjef BosmanGroupware ConsultantCommented:
What's wrong with a simple Formula agent, running on selected documents, with only these lines:

Field $SavedAddresses:= @DeleteField;
Field $SavedPorts:= @DeleteField;
Field $SavedServers:= @DeleteField
0
LotusDaveCommented:
Sjef, in my experience, most users don't know how to find location documents, even if you tell them :-)
0
mbonaciCommented:
IMHO, the point of this problem is how to push changes to all local NABs, not how to change the fields (that's no-brainer).
Of course, there's nothing wrong, deleting the fields will work the same as replacing the value with empty string (SetLocationItem).

Nevertheless, you'll have to create e-mail in which you'll paste the button and then sent that mail to all users.
Other option is to create empty db on the server, place the code on the page that opens automatically, and send db link in e-mail, but the button_in_mail solution is simpler than that.
0
Sjef BosmanGroupware ConsultantCommented:
Yes... That may be true but... If someone knows about the field $Saved Addresses, which is a field in a Location document, one might expect that that person knows how to find a Location document...
0
Sjef BosmanGroupware ConsultantCommented:
I assume it wasn't a no-brainer for jvutechnc, Marko.
0
jvutechncAuthor Commented:
LotusDave,

Are those formulas you provided or is it java or javascript?  What do I select from the drop down box when I past your code into the body?
0
mbonaciCommented:
That's why I stated that IMHO he wasn't asking that (no-brainer = trivial, isn't it).
0
jvutechncAuthor Commented:
Or is it Lotusscript that LotusDave provided?  I get all sorts of errors when I try to save your agent code.  Please advise me on how to put this into a button. Thank you again!
0
mbonaciCommented:
- create new form
 - create new button on it
 - in button's events (code) paste function SetLocationItem (go to Options and paste there - you'll see function created)
 - Then in buttons Click event type this:

Call SetLocationItem( "$SavedAddresses", "" )
Call SetLocationItem( "$SavedPorts", "" )
Call SetLocationItem( "$SavedServers", "" )

Then copy the button to new memo that you'll send to users with instructions to click on it.
0
LotusDaveCommented:
Sorry, I just copied it from our LotusScript library without checking and there are errors - here's the corrected version for the user button. I see you have been given other alternatives so maybe you don't need this now -

Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim port As Variant
      
      Set db = session.GetDatabase("", "names.nsf")
      Set view =db.GetView("Locations")
      Set doc=view.GetFirstDocument
      While Not (doc Is Nothing)
            Call doc.RemoveItem("$SaveAddresses")
            Call doc.RemoveItem("$SavedPorts")
            Call doc.RemoveItem("$SavedServers")            
            Call doc.save(True,True)
            Set doc=view.GetNextDocument(doc)
      Wend
      Messagebox "Removing Cached Addressed Completed"
      
End Sub

0
jvutechncAuthor Commented:
mbonaci,

Where is:

 - in button's events (code) paste function SetLocationItem (go to Options and paste there - you'll see function created)

Thank you.
0
mbonaciCommented:
Create a button, click on it and where it says

     Run: 'Client'     'Formula'

select LotusScript. Events appear on the left.

See the image
Clipboard01.gif
0
mbonaciCommented:
When you copy the code don't forget to select GetLocalNAB function in the code window.
Simply select all the code from my first post there and paste in Options event.
0
jvutechncAuthor Commented:
LotusDave,

Your revised client lotusscript worked great.  How about the one script for the server's directory?  I tried using but it had errors.  Any thoughts?
0
jvutechncAuthor Commented:
mbonaci,

I'd like to try your code but I can't figure out what you're saying.  I'm very experienced with coding so I appreciate if you can list step by step what needs to be done in order to do what you suggest.  Thank you.
0
jvutechncAuthor Commented:
So Again, I would like to change the $SavedAddresses field; I've included a picture that shows the entry jnpbackup2.janpakint.com.  I need to change it to jnpbackup2.janpak.com.

thank you.

Savedaddresses.gif
0
Sjef BosmanGroupware ConsultantCommented:
Instead of
      Call doc.RemoveItem("$SaveAddresses")
use
      Dim v As Variant
      v= Evaluate(|@Replace($SaveAddresses,"jnpbackup2.janpakint.com","jnpbackup2.janpak.com")|, doc)
      Call doc.ReplaceItemValue("$SaveAddresses", v)
0
Sjef BosmanGroupware ConsultantCommented:
0
mbonaciCommented:
I posted step by step instructions, so can you rather answer:
Where did you get stuck? Which step isn't understandable for you and I'll clarify?

I'm repeating the instructions here (in my previous post I included the image for step 3 so it's easier for you to find the Options section where you should paste the code):

 1.  create new form
 2.  create new button on it
 3.  in button's events (code) paste function the code I'm repeating bellow (go to Options and paste there - you'll see two functions created)
 4.  then in buttons Click event type this (I included Sjef's code in order to leave other entries the users may have - intact):

Dim v As Variant
v= Evaluate(|@Replace($SaveAddresses,"jnpbackup2.janpakint.com","jnpbackup2.janpak.com")|, doc)

Call SetLocationItem( "$SavedAddresses", v )


Then copy the button (select it on form, in Designer and paste it to new mail memo) to new memo that you'll send to users with instructions to click on it.
Sub SetLocationItem( itemname As String, itemvalue As Variant )
        'Mb¤, 14.02.2005.
        'This procedure sets an item "itemname" to value itemvalue in the current user's location doc
        Dim PrivateAddressBook As notesdatabase
        Dim CurrentLocation As notesdocument
        Dim LocationString As String, strTemp As String, LocationID As String
 
        'Set PrivateAddressBook = New Notesdatabase( "", "names.nsf" )
        Set PrivateAddressBook = GetLocalNAB()
        
        If PrivateAddressBook Is Nothing Then
                Print "Cannot get your local address book."
                Exit Sub
        End If
        
        LocationString = Session.GetEnvironmentString( "Location", True )
        
        If LocationString <> "" Then
                strTemp = Mid( LocationString, ( Instr( 1, LocationString, "," ) + 1 ) )
                LocationID = Left( strTemp, ( Instr( 1, strTemp, "," ) -1 ) )
                Set CurrentLocation = PrivateAddressBook.GetDocumentByID( LocationID )
                If Not CurrentLocation Is Nothing Then
                        Call CurrentLocation.ReplaceItemValue( itemname, itemvalue )
                        Call CurrentLocation.Save( True, False )
                Else
                        Msgbox |Unable to get current location document. Check notes.ini setting "Location".|
                        Exit Sub
                End If
        Else
                Msgbox "Unable to get the location settings. Location setting in your notes.ini is empty."
                Exit Sub
        End If     
End Sub
 
Function GetLocalNAB() As NotesDatabase
        Dim sAddressBook As String
        Dim nCommaLocation As Integer
        
        On Error Resume Next
        sAddressBook = session.GetEnvironmentString( "NAMES", True )
        nCommaLocation = Instr( sAddressBook, "," )
        If nCommaLocation > 0 Then sAddressBook = Left( sAddressBook, nCommaLocation - 1 )
        
        Set GetLocalNAB = New NotesDatabase( "", sAddressBook )
End Function

Open in new window

0
mbonaciCommented:
0

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
LotusDaveCommented:
Hi, I've been away for a few days but saw your request for the corrected server version of the agents I supplied, here it is, drop this Lotuscript between the Sub Click(Source As Button) and End Sub lines

      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim port As Variant
      Dim whichserver As String
      whichserver=Inputbox$("Which Server?")
      
      Set db=session.GetDatabase(whichserver,"names.nsf")
      Set view=db.GetView("$Locations")
      
      Set doc=view.GetFirstDocument
      While Not (doc Is Nothing)
            Call doc.RemoveItem("$SavedAddresses")
            Call doc.RemoveItem("$SavedPorts")
            Call doc.RemoveItem("$SavedServers")
            
            Call doc.save(True,True)
            Set doc=view.GetNextDocument(doc)
      Wend
      Messagebox("Removing Cached Addresses Completed")
      
Good luck,
Dave
0
jvutechncAuthor Commented:
Thank you to everyone for your help on this!!  So far I've used Lotus Dave's client script and also made a change in my Server Documents "Notes Ports" to have the correct FQDN for the servers.  

I want to test and use all your answers in order to find what will work best in my situation.  As a result, I will not close this request at this time but will continue to verify your answers over the next few days.

Thank you!
0
jvutechncAuthor Commented:
mbonaci,

Can I simply add another FQDN to the following line??  I want to add janpak.com also.  What would be the syntax?

Call SetLocationItem( "$SavedAddresses", "jnpbackup2.janpak.com" )

Thank you for reposting you working code on openntf.org.  I used it and I especially like the email message it returns!!  Awesome.  

Thank you LotusDave and everyone else for your posts and suggestions. I decided I will use Mbonaci's code to populate the $SavedAddresses field.
0
mbonaciCommented:
To place multiple values in a field you'll have to do it using array, like this:
Dim valueArray(1) As String
 
valueArray(0) = "jnpbackup2.janpakint.com"
valueArray(1) = "jnpbackup2.janpak.com"
 
 
Call SetLocationItem( "$SavedAddresses", valueArray )

Open in new window

0
jvutechncAuthor Commented:
mbonaci,

Thank you for that array code.

Thank you to everyone.  Farewell!
0
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.