LotusScript - Trying to Change a Field Value

Hello,

I have a view that has pulled in a particular set of documents in which the radio button field “AtRisk” currently has the value “Yes”. I need to change that value to another radio button choice – “No”. The code below is able to erase the selection for “Yes” selection but it won’t put in the “No” selection. Thanks for taking a look at the code and if you can offer a suggestion then Great! Thanks

Sub Initialize

Dim workspace As New NotesUIWorkspace

Dim s As New NotesSession

Dim uiview As NotesuiView

Dim view As notesview

Dim doc As NotesDocument

Dim HowMany As Integer



Set uiview=Workspace.Currentview

Set view = uiview.view	

Set Doc = View.GetFirstDocument

HowMany=Inputbox("How many Risk Status would you like to change?")

i=0

Do Until i=HowMany

	Call UIView.SelectDocument( doc )	

	Call doc.ReplaceItemValue( "AtRisk", No )

	Call doc.Save( True, True )

	Call view.Refresh	

	i=i+1

	Set doc = view.GetFirstDocument

Loop

End Sub

Subject: LotusScript - Trying to Change a Field Value

Put the quotes around the “No” in the following line and try it out.

Call doc.ReplaceItemValue( “AtRisk”, “No” )

Ganesh

Subject: RE: LotusScript - Trying to Change a Field Value

Thank you Ganesh and Tom

Matthew

Subject: RE: LotusScript - Trying to Change a Field Value

er, I mean Stan :slight_smile:

Subject: As long as you don’t start callin’ me Alice…

Subject: LotusScript - Trying to Change a Field Value

Instead of:Call doc.ReplaceItemValue( “AtRisk”, No )

try

doc.AtRisk = “No”

Subject: RE: LotusScript - Trying to Change a Field Value

Michael,

You helped a beginner today. Thank you very much – it worked.

Matthew

Subject: RE: LotusScript - Trying to Change a Field Value

There was nothing wrong with ReplaceItemValue – in fact, using the Method method is actually preferable. The problem was the missing quotes around the “No”. Without the quotation marks, your code is placing the value of a variable named No into the NotesItem. Since you likely don’t have such a variable declared and set (and seem not to be using Option Declare), an empty Variant variable called No is created in place, and will by default contain an empty string value. So you DID succedd in putting No into the field – it’s just that no is an empty string the way your code was written. The correct syntax would have been:

Call doc.ReplaceItemValue( “AtRisk”, “No” )

Subject: Try (note the ""s): Call doc.ReplaceItemValue( “AtRisk”, “No”)