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
        Else
            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
    Else
        doc.Used = "MAIL"
    End If
This was first published in May 2001

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close