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:
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:
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.
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:
Option Public Option Declare Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Set db = s .CurrentDatabase Set doc = db .CreateDocument Call ReportViewSelectionFormulas (db , doc ) Call doc .send ( False ,s .UserName ) End Sub
provided by Julian Robichaux at nsftools.com.
Sub ReportViewSelectionFormulas (db As NotesDatabase , doc As NotesDocument ) Dim s As New NotesSession Dim v As NotesView Dim out As NotesStream Dim mime As NotesMimeEntity Dim header As NotesMimeHeader Dim body As NotesMimeEntity Dim oddRow As Boolean s .ConvertMIME = False ' Do not convert MIME to rich text Call 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 = False Else out .WriteText ( |<tr style="background-color : #EEEEEE"><td>| ) oddRow = True End If out .WriteText (v . Name ) out .WriteText ( |</td><td>| ) 'The view alias If Isempty (v .Aliases ) Then out .Writetext ( |./.| ) Else Forall curAlias In v .Aliases out .WriteText (curAlias ) out .WriteText ( " " ) End Forall End If out .WriteText ( |</td><td>| ) out .WriteText (v .SelectionFormula ) out .WriteText ( |</td></tr>| ) End Forall out .Position = 0 out .WriteText ( "</table>" ) Call body .SetContentFromText (out , "text/html; charset=UTF-8" , ENC_IDENTITY_7BIT ) s .ConvertMIME = True ' Restore conversion End Sub
provided by Julian Robichaux at nsftools.com.
Posted by Stephan H Wissel on 04 April 2008 | Comments (5) | categories: Show-N-Tell Thursday