Hi,
I have a small script that needs to update a number field on the current document. Now the script runs on creation of the document so there is no copy saved on the db before that (and shouldn’t be saved on the db anyway, this is very important).
It goes something like this:
Dim workspace as New NotesUIWorkspace
Dim uidoc as NotesUIDocument
Dim rate As Integer
rate# = 5
The field I want to update is called “Control” and it is of Number type.
What I want to do is:
Call uidoc.FieldSetText(“Control”,rate#)
But of course this doesn’t work before the argument for FieldSetText needs to be of type text.
I cannot use the reference to the doc (instead of uidoc) because the document cannot be saved. I’m just trying to play with number on a form without ever saving it.
And of course the code needs to be developed using LotusScript
Any ideas?
Thanks
Remi
Subject: updating a number field with NotesUIDocument
Remi
just call uidoc.fieldsettext(“Control”, cstr(rate))
This works fine, and if you need to retrieve a value from uidoc just cdbl(uidoc.fieldgettext…) to play with numbers
hth
Dan
Subject: RE: updating a number field with NotesUIDocument
Dan,
I can’t do that… because the field Control is Number field and not a Text field… that’s why I can’t use FieldSetText at all… I’m looking for some sort of FieldSetNumber or FieldSetInteger (I know they don’t exist… but that’s what I need)…
Any suggestions?
Remi
Subject: RE: updating a number field with NotesUIDocument
Hi Remi,
From the help file:
Syntax
Call notesUIDocument.FieldSetText( fieldName$, textValue$ )
Parameters
fieldName$
String. The name of the field with the value you want to set. The field must be editable. Specify an empty string (“”) to set the value of the current field.
textValue$
String. The value you want to give to the field. If the fieldName$ is not of type text, this value is converted from text to the appropriate data type when you save the document.
So as long as your field Control is editable, you can use uidoc.fieldsettext(“Control”, cstr(rate)) and the value will be saved as a number.
However, I have found that if you use FieldSetText on a computed field, the value is saved as text no matter what the field type is.
Emily.
Subject: updating a number field with NotesUIDocument
NotesDocument (backend) object is available before the document is saved.
So try,
uidoc.document.control=rate#
cheers !!
Ashish
Subject: RE: updating a number field with NotesUIDocument
Thanks folks.
It is just what I needed…
Remi