tags:

views:

1281

answers:

2

Hi

I'm not a Notes programmer, however, for my sins, have been working on some Notes features for an in-house project recently. I need to enable/disable editing of a field depending on circumstances. It seems to me to be a fairly standard feature, I need, but I can't find any information on how to do this anywhere.

In form setup (and other field's onchange) code, something like the following:

if some requirement = true then
    textField.enable = true
else
    textField.enable = false
end if

I've seen other places where there's a work-around of conditionally hiding paragraphs based on some code, having 2 paragraphs with opposite hiding conditions, one with an editable field, the other with a computed field. However, I don't know enough about Notes to see how this is implemented (I can see it done on other forms, but there seem to be some 'magic' steps within Notes which I either can't see or don't get).

[EDIT] The reply from kerr seems to be what I'm looking for, but I still can't find out where the InputEnabled property is located. Should have said in the initial question, I'm using Notes 7.0.3.

In fairness, it doesn't matter what the circumstances are for when to enable/disable the field, it's just some boolean condition that is set, in my case only on form loading so I don't even have to worry about this changing dynamically while the form is displayed.

I've a few issues with Notes, my largest bugbear being that it's so tied so tightly to the Designer UI, which is utter shite. I can do this sort of thing programmatically in most GUI languages (C#, Java, Delphi, even VB), but I need to open property boxes in Notes and set them correctly.

This would be OK as an optional method, but forcing you to go this way means you can only work as well as the IDE lets you in this case, and the IDE here seems to actively work against you. You can't open multiple functions/scripts, you can't swap from one script to another without going back to the menus on the left, you can't easily search the codebase for occurences of variables/fields (and believe me, this is a major failing for me because either Notes or the internal codebase in my case seems to make a lot of use of global variables!), you can only work with fields though the property boxes that get displayed, you can't edit code in Designer while debugging through the main Notes client.

While the Java side of the coding is better than lotusscripts, it's still fairly crappy (why can't you debug INTO Java code?? Why do you need to re-import JAR files for each Java class, does each class have a different CLASSPATH???). Possibly this was improved in Notes 8, I hear it's based on Eclipse. Anyone know whether this is true or not?

A: 

It would help to hear more specifics about the 'circumstances', but the most common way to handle this is to use a hide when formula on the field you want to enable/disable.

Technically you are not enabling or disabling the field, just hiding it, but usually that works just as well.

Since there are few events to work with in Notes, developers commonly use the document refresh as the 'event' to cause the field to hide or show.

Let's assume you have two fields called TriggerField and Subject. Say also you want to disable the Subject based on a value in the TriggerField. The easiest way to do so is to set the TriggerField as a Dialog List type and check the "Refresh fields on keyword change" option. This means when the value of the dialog list changes, the entire document will get refreshed.

Then in your hide when formula for the Subject field, you specify your criteria for when to show or hide that field. Anytime field values change, followed by a refresh of the document (i.e. form), that hide when formula will be re-evaluated.

There are other ways, depending on your circumstances, to solve this problem. If you want to let the user refresh the form themselves, put a button on the form that calls the @Command([ViewRefreshFields]) command. You can add any other formulas to that button before the refresh command if you want to make other changes to the form at the same time.

Another option is to make a certain field display-only. Then create a button that runs LotusScript to allow users to change that display-only field. In the script you can propmt the user for a value, set the display-only field, and then call for a document refresh.

Ken Pespisa
A: 

In ND7 and up if you want to just disable the field for input, write an appropriate formula in the InputEnabled section of the field you want to disable.

So I have two fields one called Trigger, a checkbox with the value "On" and another Subject that is a text field. When Trigger is checked I want the value Subject to be enabled.

I simply put the following formula in the Input Enabled element of the field Subject:

Trigger = "On"

I also want this to be recalculated whenever the value of Trigger changes so I select the "Refresh fields on keyword change" option on the Trigger field.

If you're stuck in an older version you need to to hide paragraphs appropriately.

kerrr
This looks like it would be what I'm looking for. Where do I find the InputEnabled section? I'm coding for Notes 7.0.3 and can't find this on any of the field property tabs.See, this is my major problem with notes. I can do this in code in Java, C#, Delphi, even VB, but only via the UI in Notes???
GKelly
It's not in the field properties box, it's in the programmers pane at the bottom. When you select a field, the corresponding object will be opened in the programmers pane, where you write the Default Formula, input translation and event handeling code. One of these is Input Enabled.
kerrr