Replce existing field value with lotus script

I found this technote http://www-01.ibm.com/support/docview.wss?rs=899&uid=swg21214562 talking about how to replace existing value in SametimeServer field with null value. This is going to replace existing value for all location doc to null, my goal is to replace this value to only some of location doc not all. i.e. I do want to replace this field with only for OFFLINE and ISLAND locations but no others, can someone help modifying this piece of code for this purpose?

TIA

Sub Click(Source As Button)

Dim session As New notessession

’ 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 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

'For All The Documents in The View

While Not (doc Is Nothing)

'To overwrite a field use the ReplaceItemValue method.

'For example, the below line overwrites the SametimeServer field with the desired null entry

Call doc.replaceitemvalue (“SametimeServer”,“”)

Call doc.save (True,True)

'Get Next document

Set doc = view.getnextdocument(doc)

Wend

End If

End If

End Forall

End Sub

Subject: re: replace existing field value with lotus script

I added an if statement to test to see if the location name is “Offline” or “Island”. It will only change values on location document’s whose name is “Offline” or “Island”.I don’t vouch for the code you found, but it looks solid.

Sub Click(Source As Button)

Dim session As New notessession

' 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 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 

			'For All The Documents in The View 

			While Not (doc Is Nothing) 

		

				'To overwrite a field use the ReplaceItemValue method.

				'For example, the below line overwrites the SametimeServer field with the desired null entry

				



				'Added Code

				if (doc.getItemValue("name")(0) = "Offline") or (doc.getItemValue("name")(0) = "Island") then



					Call doc.replaceitemvalue ("SametimeServer","") 



					Call doc.save (True,True)

				End if 

				'Get Next document

				Set doc = view.getnextdocument(doc) 

			Wend

		End If

	End If 

End Forall

End Sub

Nick

Subject: need some more help on this

Thanks for help on this though while it is working for me it is not working for all please, other people get message:

Notes error: You cannot update or delete the document(s) since you are not listed as an allowable author for this document

any idea how to work around this?