Your Development & Design Resource

Lotus Notes Domino UI and Backend Development with an eye to the future!

So I was thinking... I was helping out a fellow Lotus Notes Domino developer (and reader) last night who wanted to create what I typically refer to as milestone updates of Parent/Child NotesDocuments. Simply put, when the Parent NotesDocument's Status was changed to from -- for example -- Status1 to Status2, all Children NotesDocuments would be updated. Of course, this is pretty simple once you get the concept down, but I'm brining this up as I believe the majority of us would use the following approach to address this need:

Sub Postsave(Source As Notesuidocument) Dim newstatus As String Select Case Join(source.Document.GetItemValue("status"), "") Case "Status1": newstatus = "subStatus1" Case "Status2": newstatus = "subStatus2" Case Else : newstatus = "subStatusDefault" End Select Call source.Document.Responses.StampAll("status", newstatus) End Sub

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at

Sure, this gets the job done... but what happens when your customer wants to take this Lotus Notes Client Application to the web? What happens when they want to access the NotesDatabase via a Blackberry or another mobile device?

I've talked countless times about the absolute need for Lotus Notes and Domino Application Developers to adapt their development practices and future proof their code... and the first step is often understanding the difference between UI development and Backend NotesDocument development.

Application Logic is typically integrated with the NotesUIDocument either through UI intereaction or via Form Events like QuerySave or -- as shown above -- PostSave.

Lotus Notes Domino Application Development - App Logic in the UI

Again, while this is good enough for Lotus Notes Client Application Development, you can immediately see the need to re-write all Application Logic for Web Browser Client or Mobile Device Client access. And while you might think that's not a problem -- most web/mobile-enablement projects allot for such an activity -- this approach becomes a complete maintenance nightmare when 6 months later the project champion tells you the application logic needs to change.

So we need to work smarter up-front, during the application architecture phase of the build. Specifically, we need our applications to be as future-proof as possible and adaptive to the ever-changing business environment where our applications (and most importantly our users) live.

To do that, we simply move the App Logic away from the NotesUIDocument or Form and into the backend of the NotesDatabase.

Lotus Notes Domino Application Development - App Logic in the Backend

To apply this approach to our above example, let's revisit our PostSave Event.

Sub Postsave(Source As Notesuidocument) Call logic(source.Document) End Sub

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at

That handles our NotesUIDocument/Form for the Lotus Notes Client, but what about the Web Browser or Mobile Device Clients?

I use a $$Return Computed For Display Text Field with the following Formula:

"[" + basehref + "logic?OpenAgent&DOCID=" + @Text(@DocumentUniqueID) + "]"

(basehref in the above example is another Computed For Display Text Field that evaluates the Web URL to the give NotesDatabase...)

As for the logic Agent Design Element:

Sub Initialize
Dim s As New NotesSession Dim db As NotesDatabase Dim a As NotesAgent Dim cdoc As NotesDocument Dim pdoc As NotesDocument Dim pdocid As String Dim qs As Variant Set db = s.CurrentDatabase Set a = s.CurrentAgent Set cdoc = s.DocumentContext
pdocid = cdoc.Query_String_Decoded(0)
If pdocid <> "" Then qs = Split(pdocid, "&DOCID=") pdocid = qs(1) Else MsgBox a.Name + |: Unable to process UniversalDocID from Report Form Elements $$Return| MsgBox a.Name + |: $$Return redirected to | + pdocid Print |[$DefaultView]| Exit Sub End If
Set pdoc = db.GetDocumentByUNID(pdocid) If pdoc Is Nothing Then MsgBox a.Name + |: Can't find a document where | + pdocid + | = UniversalDocID| Print |[$DefaultView]| Exit Sub End If
Call logic(pdoc)
End Sub

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at

Your logic Function can now handle all workflow and business logic for your given NotesDocument, from updating Status fields to maintaining NotesDocument History tracking fields to creating milestone event-driven pushes to workflow notification utilities.

Simply store all of this application logic in your logic Function in a Script Library, and you can switch out User Interfaces for your applications at will!

... of course, you could always write a business logic controller engine that uses Project Champion-maintained NotesDocuments for it's configuration -- but that's getting into MVC, and we wouldn't want to do that now... would we?

About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.

More from is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.