SnTT: Adding a Database Size Indicator to Notes 8
April 24th, 2008 by Corey Davis
I have been meaning to post this SnTT for several weeks now, but have not found the time to finish it. Chris Miller’s post yesterday, Do Your Users Understand a Stoplight Signal?, points out the new and improved quota reporting in the 8.0.1 mail template and has prompted me to finish this post. Yes, I agree, the new graphical quota reporting is a beautiful thing. But, what to do if you (or your customer) does not use quotas yet wants to provide some type of theoretical limit to their users and display a disk usage meter just like this one for quotas?
If your first reaction is to just throw your arms up in the air and say “Oh, come on! Just implement the quotas!” then you would be exactly right. However, that would not make for a very fun SnTT now would it? So, here’s what I did:


First, you begin by stealing, err, leveraging Martin Vereecken’s work. His implementation addresses Notes 7 and below, but we are concerned with Notes 8. So, we start by copying the DbSizeGraphic form from Martin’s example into our mail template (you will notice that in my example the form is called FileSize; I only changed it because FileSize is the legacy name of the form we have used to display the file size in mail files since R5).

I then modified the PostOpen code to allow for the fact that we have this hardcoded theoretical file size limit and not quotas. And don’t even get on my ass about hardcoding, ‘kay? I despise hardcoding values as much as the next developer, but I did it anyway. Deal with it.
Sub Postopen(Source As Notesuidocument)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db=session.CurrentDatabase
Dim doc As NotesDocument
Set doc=Source.DocumentSize = Cdbl(db.Size) / 1048576
MaxSize = 140 ‘Hard-coding quota size; remove if real quotas are used
doc.Score=Round(Round(Size,0)/Round(MaxSize,0)*100,0)
doc.FileSize = Cstr(Round(Size,0))+” MB used”
doc.SizeAllowed = Cstr(Round(MaxSize,0)) & ” MB allowed”
Source.Refresh
End Sub
I made a few other changes such as getting rid of the SizeDescription field and added a FileSize and SizeAllowed field. I also changed the background color of the form to RGB 176,192,208 to match the Notes 8 colors.
Next, we need to get this into the sidebar. In Notes 7 that would mean modifying the framesets, but that doesn’t work in Notes 8 because the PIM applications are composite applications. So, we need to modify the template in the Composite Application Editor. To do this, open the template in the Notes client. Then, select the Action -> Edit Application menu option. This will launch the CAE.
Now we need to add the File Size component so that we can add it to the Mail page. To do this, select the menu option Tools -> Component Palette -> Add Components -> Add NSF Component. If you are asked to switch to the My Palette palette select OK. You should now be presented with a New NSF Component dialog box.

Give it a name and description, then click the Browse button next to the Notes URL field in order to assign the form. In the Locate Object dialog, the Kind of Object is Form, the Application is - Current Database -, and the Form is FileSize. Click OK. This will place you back in the New NSF Component dialog. Press OK.

To actually add the new FileSize component to the application, open the right-side Component Palette if it is not already open. Find the FileSize component, probably under General, and drag it under the Notes Mail Mini View component.

You will need to adjust the height to your liking. When you are finished, select the menu option File -> Finished Editing. When asked if you want to keep the changes, answer Yes.
And that is it. Now that you have the component in place, if in the future you need to change the code in the FileSize form you can without needing to go back into the CAE.
While this works, there are some gotchas. First, users can re-size the components and essentially hide the disk space meter. Also, small window sizes will break up the meter. I can find no way to prevent either from happening. But, the worst problem is that once the database is opened the meter is static. A user can add or remove hundreds of meg’s of data and the meter will not change. I toyed a little with timers and such, but that really didn’t work out very well. If I find a good solution I will post it, but this is far from a priority at the moment, so I issue a challenge to all of you to find a good solution to these gotchas or a better solution to the problem that I present. And, yes, issuing a challenge on your blog to solve a problem is really just a way for me to get you to do my job for me. But just think of the momentary fame you will bask in should you solve this problem!
Related Links:
BizzyBee’s: Notes Mail Database Size Indicator - graphic version
IDoNotes: Do Your Users Understand a Stoplight Signal?

Follow me on Twitter



April 25th, 2008 at 12:24 pm
Nice work. You can also cheat and set a crazy high quota number no one would hit just to get it to show also. Not good for users since the word quotas then shows. But fun to play with