Background Color On Documents

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
take over.

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.
(Declarations, Globals)
Dim GlobalSaveFlag as Integer


GlobalSaveFlag = Continue ' So that if anything else modifies
' Continue, it is detected.
End Sub


If GlobalSaveFlag Then
' Remove?
Call document.RemoveItem("$PaperColor")
' Change?
document.~$PaperColor = ... ' Whatever
End If
End Sub

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.