wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

View Selection Formulas


Application performance in Notes and Domino can greatly vary depending on the number of views and the view selection formulas you use. When inheriting databases applications for maintainance there is no real easy way to get an overview what view selection formulas have been used. So I did write myself a function that creates a document with such an overview table.See the function below. To test it I simply copy it into an agent and call it for the current database.
Of course you could think of running it against multiple databases or altering the html with some Ajax stuff to make it sortable. Here is my test agent:
 
OptionPublicOptionDeclareSubInitializeDim s AsNewNotesSessionDim db AsNotesDatabaseDim doc AsNotesDocumentSet db = s .CurrentDatabase Set doc = db .CreateDocument Call ReportViewSelectionFormulas (db , doc )Call doc .send (False,s .UserName )EndSub
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.
Update: Sorry folks, got the wrong code in the core functionsm fixed now. Enjoy!and here the core function:
 
Sub ReportViewSelectionFormulas (db AsNotesDatabase, doc AsNotesDocument)Dim s AsNewNotesSessionDim v AsNotesViewDim out AsNotesStreamDim mime AsNotesMimeEntityDim header AsNotesMimeHeaderDim body AsNotesMimeEntityDim oddRow AsBoolean s .ConvertMIME =False' Do not convert MIME to rich textCall doc .ReplaceItemValue ("Form","Memo")Set mime = doc .CreateMIMEEntity Set header = mime .CreateHeader ("Subject")Set body = mime .CreateChildEntity Call header .SetHeaderVal ("View selection formula report for "+db .Title )Set header = mime .CreateHeader ("SendTo")Call header .SetHeaderVal (s .UserName )Set out = s .CreateStream oddRow =True out .WriteText (|<style>|) out .WriteText (|table {width : 100%; padding : 3px; border-left : 1px solid gray; border-top : 1px solid gray} |) out .WriteText (|body, th, td {text-align : left, font-family : Verdana, Arial, sans-serif} |) out .WriteText (|th {background-color : #FFCCCC} |) out .WriteText (|h1 {background-color : #FF9999; border-bottom : 2px black; font-family : Arial, sans-serif; font-size : large} |) out .WriteText (|td, th { border-bottom : 1px solid gray; border-right : 1px solid gray} |) out .WriteText (|</style>|) out .WriteText (|<h1>|) out .WriteText (db .Title ) out .WriteText (|</h1>|) out .WriteText (|<table width="100%"><tr><th>View</th><th>Alias</th><th>Selection Formula</th></tr>|)Forall curView In db .Views Set v = curView If oddRow Then out .WriteText (|<tr><td>|) oddRow =FalseElse out .WriteText (|<tr style="background-color : #EEEEEE"><td>|) oddRow =TrueEndIf out .WriteText (v .Name) out .WriteText (|</td><td>|)'The view aliasIfIsempty(v .Aliases )Then out .Writetext (|./.|)ElseForall curAlias In v .Aliases out .WriteText (curAlias ) out .WriteText (" ")EndForallEndIf out .WriteText (|</td><td>|) out .WriteText (v .SelectionFormula ) out .WriteText (|</td></tr>|)EndForall out .Position = 0 out .WriteText ("</table>")Call body .SetContentFromText (out ,"text/html; charset=UTF-8", ENC_IDENTITY_7BIT ) s .ConvertMIME =True' Restore conversionEndSub
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

Posted by on 04 April 2008 | Comments (5) | categories: Show-N-Tell Thursday

Comments

  1. posted by Giuseppe on Saturday 05 April 2008 AD:
    something wrong with the "core function" ?
  2. posted by tom on Saturday 05 April 2008 AD:
    I concur with #1. Methinks there was a cut/paste malfunction. Emoticon biggrin.gif
  3. posted by Thomas BAhn on Thursday 10 April 2008 AD:
    Hi Stephan,

    for the fast overview the Design Synopsis could be sufficient. Just deactivate everything in the details for views, but the selection formula, and add all views to the synopsis.

    It not nice, but fast, and works without design modifications.

    Thomas
  4. posted by Stephan H. Wissel on Thursday 10 April 2008 AD:
    @Thomas,

    you are right, Synopsis would work. My example code however is taken out of context. I added the sub initialize for illustration only. The full code actually lives in a utility database, that scans the design of external databases, so I actually don't change the design either. It is one part of a "brute force" view tuning tool. Stay tuned for more on that.
  5. posted by Eric Yan on Thursday 17 December 2009 AD:
    Set header = mime.CreateHeader("Subject")
    Call header.SetHeaderVal( subject )

    if subject to be chinese characters,there maybe some wrong.
    many "!!" have being added to the subject.