LotusScript - Enable Local Replication

Hi all,

I want to design a button to send to new Blackberry Users.

This button needs to Enable Replication in the current Location Document.

My code can locate and read the Location doc but I cannot seem to change the Item Values. No Error appears.

Any Ideas?

(The code has a few extra checks to see if it is in Edit mode or not. These will be removed later.)

Sub Click(Source As Button)

'Find Current Location Document NoteID

Dim session As New NotesSession

Dim location As String

Dim rightstr As String

Dim noteid As String

location = session.GetEnvironmentString("Location", True)

rightstr = Strright(location, ",")

noteid = Strleft(rightstr, ",")



Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

If uidoc.EditMode Then

	If uidoc.IsNewDoc Then

		Messagebox 	("This is a new document. Not Good")

	Else

		Dim db As New NotesDatabase("", "names.nsf")

		Dim doc As NotesDocument

		If Not db.IsOpen Then

			Messagebox "Cannot open Personal Address Book"

		Else			

			Dim notesitem As NotesItem				

			Set doc = db.GetDocumentByID("9D6")

			Set notesItem = doc.ReplaceItemValue( "ReplicationEnabled", "1")

			Call doc.save(True,False)

			Call workspace.SetCurrentLocation( "Office" )

		End If

	End If

Else

	Messagebox 	("Document is not in Edit Mode. Scenario to be tested")

End If

End Sub

Subject: For those that didn’t answer…The answer!

Sub Click(Source As Button)'Find Current Location Document NoteID

Dim workspace As New NotesUIWorkspace	

Dim session As New NotesSession

Dim uidoc As NotesUIDocument	

Dim doc As NotesDocument

Dim notesitem As NotesItem

Dim rtitem As NotesRichTextItem		

Dim location As String

Dim rightstr As String

Dim noteid As String

location = session.GetEnvironmentString("Location", True)

rightstr = Strright(location, ",")

noteid = Strleft(rightstr, ",")

'Set New Location Setting Values

Set uidoc = workspace.CurrentDocument

If uidoc.EditMode Then

	Messagebox 	("This document is in Edit Mode. Please do not use button in Edit Mode")

Else

'Start Button Actions

	Dim db As New NotesDatabase("", "names.nsf")		

	Dim reply As NotesDocument

	Dim memo As NotesDocument

	

	Set memo = uidoc.Document

	Set reply = memo.CreateReplyMessage( False )

	

	If Not db.IsOpen Then			

'Setup Mail Message to advise administrator of error

		Set rtitem = New NotesRichTextItem( reply, "Body" )

		Call rtitem.AppendText( "Blackberry Update Button Failed")

		Call rtitem.AddNewLine( 1 )			

		Call rtitem.AppendText( "Please call the user")

		

		reply.Subject = "Re: " & memo.Subject(0) 		

		Call reply.Send( False )

		Messagebox "Cannot update your settings. Your Administrator has been advised to contact you."

	Else						

'Activate Replication			

		Set doc = db.GetDocumentByID(noteid)

		Set notesItem = doc.ReplaceItemValue( "ReplicationEnabled", "1")

		Set notesItem = doc.ReplaceItemValue( "ReplicateAtStart", "1")

		Set notesItem = doc.ReplaceItemValue( "Enabled", "1")

		Set notesItem = doc.ReplaceItemValue( "Schedule", "00:01:00 - 23:59:00")

		Set notesItem = doc.ReplaceItemValue( "Interval", "10")

		Call doc.save(True,False)

		Messagebox "Activated. Personal Contacts will be synchronised with your Blackberry Device shortly"

'Send Detailed Message to administrator

		Set rtitem = New NotesRichTextItem( reply, "Body" )

		Call rtitem.AppendText( "Blackberry Update Button Ran Successfully")

		Call rtitem.AddNewLine( 1 )			

		Call rtitem.AddNewLine( 1 )			

		Call rtitem.AppendText( "Replication Enabled = ")

		Call rtitem.AppendText( doc.ReplicationEnabled(0))

	End If

	

	reply.Subject = "Re: " & memo.Subject(0) 		

	Call reply.Send( False )

End If

End Sub