Can someone please help convert this one line of code from Formula to Lotus Script?

I used to use this piece of code to perform a lookup which worked flawlessly when I used it in the Formula language. However, our code has moved to Lotus Script and this line of code in the Lotus Script isn’t working correctly.

MailQuotaFormula = Evaluate (|@DbLookup(“”:“”; @Subset(@DbName;1) : “names.nsf”; “($MailFileQuotaView)”; @Name([CN]; @V3UserName) ; 2)|)

MailQuotaResults = MailQuotaFormula(0)

I had declared MailQuotaFormula as a Variant and MailQuotaResults as a String. The code works great for a short while (say, a week) and then all of a sudden one more users get an error “Variant does not contain a container”. Since I couldn’t get the error to go away, I just pulled the code from the templates to stop performing the lookups.

So basically, its just a simple lookup in the Domino Directory, in the ($MailFileQuotaView) view, search for a name and give me the value next to it. There surely has to be a more reliable way to do this and I’d be very grateful if someone could take just one moment to help me out.

Subject: Formula converted to LotusScript

Try this…*****************************

Option Public

Option Declare

Sub Initialize

Dim Session As New NotesSession

Dim CurrDb As NotesDatabase

Dim NamesDb As NotesDatabase

Dim MailQuotaView As NotesView

Dim QuotaDoc As NotesDocument

Dim MailQuotaResults As Variant



' Error Handler

On Error Goto Error_Handler



Set CurrDb = Session.CurrentDatabase

Set NamesDb = New NotesDatabase(CurrDb.Server, "names.nsf")

If Not NamesDb.IsOpen Then

	Messagebox "The address book could not be found.", 0+16, "Address Book Not Found"

	Exit Sub

End If



Set MailQuotaView = NamesDb.GetView("($MailFileQuotaView)")

If MailQuotaView Is Nothing Then

	Messagebox "The $MailFileQuotaView could not be found in the address book.", 0+16, "Expected View Not Found"

	Exit Sub

End If



Set QuotaDoc = MailQuotaView.GetDocumentByKey(Session.CommonUserName, True)

If QuotaDoc Is Nothing Then

	Messagebox "A quota document could not be found for " & Session.CommonUserName & ".", 0+48, "Quota Document Not Found"

	Exit Sub

End If



MailQuotaResults = QuotaDoc.QuotaValue(0)	' Change field name to correct quota field name in your document



Messagebox "The quota for " & Session.CommonUserName & " is " & Trim(Cstr(MailQuotaResults)) & ".", 0+64, "Quota for " & Session.CommonUserName



Exit Sub

Error_Handler:

Print "An error has occurred on line " & Trim(Cstr(Erl)) & ": " & Error$ & " (" & Trim(Cstr(Err)) & ")"

Exit Sub

End Sub

Subject: That Worked

I can’t thank you enough - that worked like a champ!

Subject: Happy to help!

Subject: notesDatabase.SizeQuota

Are you doing this for the current user’s mail database? Why not just open their mailfile and use notesDatabase.SizeQuota ? Check it out in designer help - there’s an example that gives the quota and warning size.