FieldGetText and Cannot locate field error

I have a problem where a tabbed table within a tabbed table has a computed subform that has a radio button with an OnChange script. When the OnChange event fires on a new document, FieldGetText can’t get the value of the current field.

It’s a siimple call to uidoc.FieldGetText(“VolumeUnit”) while I’m changing the VolumeUnit field. Calling uidoc.FieldGetText on another field above VolumeUnite works just fine. But I need to test what the user just set the radio field value to. Once the document is saved, it works just fine.

My only workaround so far is to open a view and then compose the document with the view open. My “compose” action button is just an outline entry, but now I’ve changed it to open a view first. I would rather not open the view first, because that’s messy, but FieldGetText doesn’t work otherwise. I have thought I might be able to blur then focus again on the field, but that seems kludgy.

Any other ideas?

This code works, but I don’t want to open the view:

@Command([OpenView];“vwProjectsMyProjects”);

@Command([Compose];“”;“Project”)

Subject: RE: FieldGetText and Cannot locate field error

It sounds like this is a keyword field. Are you also refreshing fields on keyword change? Does the field have a calculated keyword formula? Is it set to refresh choices on document refresh? What’s the keyword formula? Are you sure you know what the formula returns?

Try using the back-end NotesDocument instead of reading the value from the NotesUIDocument.

Subject: RE: FieldGetText and Cannot locate field error

Sorry so slow responding - went on vacation and forgot.

VolumeUnit is a radio button that can be set to Lbs or Metric Tons. These two choices are entered in a list, one per line, so there is no formula. The default is Metric tons. Refresh fields on keyword change is checked. That enables me to show and recalculate either lbs or metric tons depending on which Volume Unit the user prefers to enter and show.

I appreciate the suggestion to try the back end Notes document; however, I am under the impression the back end doc is not available until I perform a save, and I cannot perform a save while the user is still entering data.

I promise this all works if the doc is composed from a view, and we just pushed to production that way. So I’m not losing sleep over it any more — it just seemed strange that this would work, and the normal call to FieldGetText wouldn’t.

Subject: RE: FieldGetText and Cannot locate field error

“I appreciate the suggestion to try the back end Notes document; however, I am under the impression the back end doc is not available until I perform a save, …”

So, get rid of that wrong impression.

There are use cases for FieldGetText and FieldSetText, but most of the time simple back-end access is easier to handle.

Subject: RE: FieldGetText and Cannot locate field error

Well, you’re right — I had the wrong impression. I’m still not having much luck with my code, but at least I know what my options are now and that FieldGetText won’t do it.

Subject: RE: FieldGetText and Cannot locate field error

Unfortunately, I always found the OnChange event of fields to behave … well, not consistently the way I would have found it useful. Same for the OnFocus event.

Sometimes, it even makes a difference, if the field is displayed in OS or Notes style. At least in 6.5.4 and 6.5.5 I had a case, when the OnFocus would fire before the forms PostOpen (with one of the display options, don’t remember off hands which one). Now, what kind of logic is that?

I’m afraid, that in your case the straight way might turn out to simply not work.

Subject: RE: FieldGetText and Cannot locate field error

Wow that’s a nice tip that will probably come in handy to lots of people trying to debug these events.

I did have to use the back-end value to get my code to work, and I had to use it everywhere. For a radio button, the back-end value is the alias and the front-end value is the displayed option — so this took a lot of careful examination of which value I was testing. Also, I ultimatedly had to put my functions in a script library.

Thanks to you and Andre for your tips.