Change a form's background color in the Notes Client via script

I used this trick in the R5 mail template to change the color of the DiskSpace display (top left corner of the mail db in R5). Background is red if your over your quota, magenta if you are 10% near your quota, green (default notes green color) if otherwise.

The PostOpen event of the DiskUsage form has LotusScript to set a text variable by the name bgColor to "red" if user is over his disk quota, and to "magenta" if user is 10% near his quota. Default value for bgColor is "" (empty).

The onLoad event (JavaScript event) of the DiskUsage form is called after the PostOpen event (found this out by trial and error). I added one line of JavaScript code to set the form's background color to whatever was set in the bgColor variable on the form. document.bgColor = document.forms[0].bgColor.value;

Note: If bgColor is set to "" then the form background color is not changed and remains what it currently is set to.

Do not forget to make the table color transparent and remove the borders so the form's background color shows thru.

I am sure there is no equivalent of this code in LotusScript or formula language.

This concept and variations of this idea can be used in lots of Notes applications to improve cosmetics (It works both in the Notes Client and from the Web).

onLoad event has the one line of javascript below.
document.bgColor = document.forms[0].bgColor.value;

postopen event has the code below.
    Dim session As New notessession
    Dim db As notesdatabase
    Dim doc As notesdocument

    Set db = session.currentdatabase
    Set doc = source.document

    ManagerFound = False
    Forall Names In db.Managers
        If (Instr(Names,session.CommonUserName) <> 0) Then
            ManagerFound = True
            Exit Forall
        End If
    End Forall

    If (ManagerFound) Then
        dbsize = (db.size)/1024
        dbmax = db.sizequota
        If dbmax = 0 Then
            percent = 0
            percent = (dbsize/dbmax)
    End If
    used% = (percent*100)
    dbQuota = dbmax/1024
    dbFileSize = dbsize/1024

    doc.Used = "Used: " & Cint(used%) & "%"
    doc.Free = "Free : " & Cint(100 - used%) & "%"
    doc.Quota = "Quota: " & Format((dbQuota), "Fixed") & "MB"
    doc.FileSize = "Size : " & Format((dbFileSize) , "Fixed") & "MB"

    ' Set Background Color depending on quota and size ratio
        dbDifference = dbQuota - dbFileSize
        If dbDifference < 0 Then
            doc.bgColor = "red"
' Set background color to RED indicating that you are over your quota
        Elseif (dbDifference < (dbQuota/10) ) Then
            doc.bgColor = "magenta"
' Set background color to MAGENTA indicating that you are 10% close to quota
        End If
        doc.Used = "MAIL"
    End If

This was first published in May 2001

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.