Tuesday, February 5, 2008

ReadableLookups: Global constants for forms/subforms

This technique is probably overkill on smaller applications. It's quite verbose compared to writing the values directly into fields/computed texts. Long living, ever changing applications may benefit using this technique though, maintainability-wise.

Basically, the technique is a shared, computed for display field that you put in all your forms. This field may contain the names of lookup-views, index of lookup-columns, replica-id's, filepaths to co-existing applications, et cetera.

Due to the nature of the readable lookups, there's no problem with inline comments in the field, or re-organizing the "constants".

Example of field

To extract a value from the field, you have to use quite a verbose syntax, but if the constant is used a lot of places, the added verbosity is worth it, as you only have to change the value one place, in the shared field.

Example of extraction of value from constants-field:

(name of shared field, SF_CONSTANTS)

If you want the Notes/Domino constants available to Javascript/etc on the web as XML, simply put the field in a form with content-type: text/xml. Add a document-node (APPLICATION_CONSTANTS in the example below), and you have access to the constants on the web as well.

The form
Example of output XML

Since the constants are in a field, the values are also available to LotusScript when working with documents.

Simple function to extract values in LS.

PS! Remember to put the field at the top of the form, so that it is available to all the other fields in the form

1 comments:

tbahn said...

Nice technique.

One drawback I see is that "Computed for display" fields aren't computed for NotesDocument.ComputeWithForm. I use this function sometimes, therefore I unfortunately cannot use your trick.