View member feedback to this tip.
Editor's Note: Version one of this tip, Set field value/type via smart icon by Janet Rogers, was submitted on Sept. 4, 2001 and won the SearchDomino.com Tips Contest that month. The following tip is another version of Janet's.
This formula can be pasted into a custom smart icon (tool button) in the Notes client. It allows you to arbitrarily set the value of any field on the document. Using the formula, you can easily change field values during testing without having to write an agent or go through all steps of a workflow, etc.
This improved version uses the existing value and type of the field, if it already exists.
As in the original, when used in a smart icon button, this formula allows you to set both field value and/or data type of any Notes document on the fly. It covers all data types and allows changes to single or multiple value fields.
Code
View member feedback to this tip.
Editor's Note: Version one of this tip, Set field value/type via smart icon by Janet Rogers, was submitted on Sept. 4, 2001 and won the SearchDomino.com Tips Contest that month. The following tip is another version of Janet's.
This formula can be pasted into a custom smart icon (tool button) in the Notes client. It allows you to arbitrarily set the value of any field on the document. Using the formula, you can easily change field values during testing without having to write an agent or go through all steps of a workflow, etc.
This improved version uses the existing value and type of the field, if it already exists.
As in the original, when used in a smart icon button, this formula allows you to set both field value and/or data type of any Notes document on the fly. It covers all data types and allows changes to single or multiple value fields.
MEMBER FEEDBACK TO THIS TIP
The browser, of course, wordwrapped the text for the formula, so I had to edit the text to
To continue reading for free, register below or login
To read more you must become a member of SearchDomino.com
');
// -->

get the tip to work. However, after that I get an "errorValue" in the default value of the field. I put some debug code in and discovered that the @GetDocField is returning an error:
"@SetDocField and @GetDocField cannot access the document currently being computed."
-- Don C.
*************************************************
I pasted your code into a smart icon and it doesn't work.
The "Change Field" prompt box has "errorTemp" in it so I assume something is amiss in the "currValueTemp" field or possibly in the "theField" field.
Anyone else ask you about this?
-- Bob M.
*************************************************
I liked the tip. I dropped the code into a smart icon and had no problems. The only modification I made was to add some code to be able to delete a field. I added one line to include the delete option in the field type prompt, as shown below:
Then, I added the line below to the @If that handles the field type:
-- Dave P.
*************************************************
This is a good refinement for this tool. However, it can be further enhanced by changing the first prompt from:
Doing this allows you to add new fields to a form, a task that is sometimes necessary during the early stages of development.
-- Dominic H.
*************************************************
I tried this code out and it seems to work just fine for me. I'm not sure why those others are having problems, but maybe they could post their code and we could help them find out what's wrong.
-- SearchDomino.com member
*************************************************
I also have had problems. For the record, I am running R5.0.10 on Win95. As a check, I have inserted three extra @prompt lines. The first two confirm that the field has been correctly selected and that the correct UNID is in place. The third returns "errorvalue," indicating that the field is not available. Attempts to modify the field directly without querying its availability were similarly unsuccessful.
-- Richard H.
*************************************************
I have been using this code since it was posted and as an inexperienced developer, I use it DAILY! It has worked for most things that I want to do and I have NEVER had to adjust it at all. I'm going to try to add the first two member feedback posts from here. BUT I'll make sure to keep my original one! Thanks for the biggest time-saver I have found!
-- Pamela D.
*************************************************
The code works in ND6 but in Notes version 5 you cannot retrieve the value of an existing field -- it always returns the value "errorTemp" due to an error mentioned in another comment: "@SetDocField and @GetDocField cannot access the document currently being computed."
Beats me why!!!!
-- Richard K.
*************************************************
I would like this tip very much if it would work. But in my version of Notes (5.0.10, German), it does not work. I had to change the brackets in the REM lines in the beginning to quotation marks. Now I get the same error as Don C. in the first comment. Do you use Notes 6 to have @GetDocField working on the current document?
-- Stephan S.
*************************************************
Thinking about the R5/R6 difference, it seemed a good idea to try:
etc.
Unfortunately this made no difference, nor did a line declaring
at the beginning.
The good news is that on my system at any rate, provided that the document is open for editing, the unmodified code inserts the new value into the desired field, even though the old value is not retrieved. This works for computed as well as editable fields. The bad news is that although the field type changes to the requested type, this change is lost when the document is saved.
So the limited functionality available under R5 can be obtained with a greatly cut-down version:
If a text list is inserted into a text field, then the field type changes to text list for that document only. The change persists, even if a single value is subsequently inserted.
-- Richard H.
*************************************************
I have not problems running this from a view. I do have problems running this when the document is open in R5.
-- Ralph B.
Do you have comments of your own? Let us know.