Everybody knows that you can play with the background color of forms, and also
that individual documents can be assigned a background color (or even
background graphics). Just enter a document in edit mode, choose Document
Properties, and use the Background-tab.
This is a little fun. What's a lot of fun is what you can do this in code. The
whole secret is the field $PaperColor. This is a number field which holds the
integer value for the color that is to be used for the background. The possible
values can be deducted from a standard Notes color picker. Just count left to
right and top to bottom, starting with zero (0=black, 1=white, 2=red, 3=green,
4=blue etc.) and skipping the first two lines (the standard 16-color palette).
Every row starts with a multiple of 16 (0, 16, 32 etc.) With this knowledge you
can indicate the status of documents, e.g. customers who don't pay their bills
show up in heavy red, approved documents get a green background etc. And when
the indicator is no longer needed, you can remove it and let the form default
As with most things Notes-like there is a small problem. You can't change the
field in QuerySave. (I think it's got something to do with the sequence a
document follows backend when it is saved.) You have to do all dynamic changes
in QueryClose, which means you'll have to set a global flag indicating whether
the document has been saved. See the example in the code below.
Oh, and the code contains another neat trick: $-fields *can* be referenced by
extended syntax. Just place a ~ (tilde) before the $-sign and everything is OK.
Dim GlobalSaveFlag as Integer
GlobalSaveFlag = Continue ' So that if anything else modifies
' Continue, it is detected.
If GlobalSaveFlag Then
document.~$PaperColor = ... ' Whatever
This was first published in November 2000