Lotus Notes Button to make changes to Location Documents

I am trying to create a Button that i can email to users to make a few changes in the local address book.

The button needs to change 2 things in any location document. It needs to change the “Domino Directory Server” on the “Servers” tab and the “Mail Addressing” on the “Mail” tab.

The code below makes the changes but the changes do not seem to go into effect until you manually open the location doc for editing, edit any field and then save. Any ideas/suggestions?

'Modifies directory server and mail addressing fields

'Sets all of the location documents

Sub Click(Source As Button)

Dim session As New notessession

Dim workspace As New NotesUIWorkspace

Dim uiw As New notesuiworkspace

Dim uidoc As notesuidocument

Set uidoc = uiw.currentdocument

Dim doc As notesdocument

Set doc = uidoc.document

'For The Current User in The Current Session, Get All The NABs

Forall books In session.addressbooks

'Check If The Current NAB is Private or Public

'If The NAB Is Private, Than It Should Be Your Personal NAB

If books.isprivateaddressbook And books.filename = “names.nsf” Then

'Verify if The NAB is Open, If Not, Open it

If Not(Books.isopen) Then

Call Books.open(“”,books.filename)

'Now Get All The Documents in The Location View

Set view = books.getview(“Locations”)

Set doc = view.getfirstdocument

While Not (doc Is Nothing)

'Modify Mail Addressing

Call doc.replaceitemvalue (“directoryserver”,“MAIL01/SRV/PDCO”)

Call doc.replaceitemvalue (“mailaddressing”,“Local and Server”)

Call doc.save (True,True)

Set doc = view.getnextdocument(doc)

Wend

End If

End If

End Forall

Call uidoc.send

End Sub

Subject: Lotus Notes Button to make changes to Location Documents

How about adding a call doc.ComputeWithForm just before the doc.save?

Does that help?

Subject: RE: Lotus Notes Button to make changes to Location Documents

That gives me a “Document can not save due to a script error”

Subject: RE: Lotus Notes Button to make changes to Location Documents

might have something to do with the way you’re setting the directoryserver field, try it in canonical format

Call doc.replaceitemvalue (“directoryserver”,“CN=MAIL01/OU=SRV/O=PDCO”)

Subject: RE: Lotus Notes Button to make changes to Location Documents

Just figured it out.

if you change:

Call doc.replaceitemvalue (“mailaddressing”,“Local and Server”)

to

Call doc.replaceitemvalue (“mailaddressing”,“2”)

it works.

thanks for the suggestions

Subject: Why not use Policy Based Administration?