Archive for September, 2007

Demo ‘collapse embedded view by default’

Today it was here very rainy so I hate plenty of time to do those things you wtill wanted/needed/were asked to do. For example I receive frequently question to send a working example for collapsing an embedded view by default. I have explained the principles in a previous writing.

Therefor I keep this blog entry short with just remaining a reference to the location where you can download a working-example.

Leave a Comment

Export to Excel wizard

I was asked to take a look at an existing application, and come up with suggestions to improve performance.

In a first look I found that most of the views, especially the default to be opened view, were set to refresh the index automatically… you can imagine how much the users love to start working with this application which has readers fields on all documents (NOT!).

When I asked were all the views were needed for, I got as reply: to have it in a format we want to make graphics in Excel.

Okej, why not delete these ‘views to be exported for Excel’ and replace them with an export functionality?

export start button

So what where the needs?

  1. a set of fields for different types of forms that should be manageble by the application manager
  2. an export-mechanism to Excel which should be easy to understand for end-users and give them the opportunity to create customizable exports.

1) Export profiles

In order to create so-called Export profiles for different Notes forms I needed an additional form (ExcelFormExport) where the administrator can:

  • select the desired form for export (FieldA)
  • select the form-fields that should be available for export (FieldB)

This last field is being calculated when FieldA is being exited:

Sub Exiting(Source As Field)
 Dim workspace As New NotesUIWorkspace
 Dim uidoc As NotesUIDocument
 Set uidoc = workspace.CurrentDocument 
 fieldvalue = Lcase(uidoc.FieldGetText(“Tx_FormSelected”))
 Dim doc As NotesDocument
 Set doc = uidoc.document
 If fieldvalue <> “” Then
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Set db = session.CurrentDatabase  
  Forall form In db.Forms
   If Lcase(form.Name) = fieldvalue Then
    If Isempty(form.Fields) Then
     Messagebox form.Name & ” has no fields…”
    Else
     ’collecting the form fields
     Dim arrFieldNames() As String
     Dim iCount As Integer
     iCount = 0     
     Redim arrFieldNames(0)
     Forall field In form.Fields      
      Redim Preserve arrFieldNames(iCount)
      arrFieldNames(iCount) = field
      iCount = iCount + 1
     End Forall     
     Call doc.ReplaceItemValue(“Tx_FormFields”, BubbleSort(arrFieldNames))     
     Call uidoc.Refresh()     
    End If
    Exit Sub
   End If
  End Forall
  Messagebox “The form “”" & formNameIn & “”" does not exist”
 End If
End Sub

Bubblesort is a function which sorts the array with fieldnames:

Function BubbleSort(vtList As Variant) As Variant
 Dim tmpValue As Variant
 Dim x As Integer, y As Integer 
 If Ubound(vtList) = 1 Then
  BubbleSort = vtList
  Exit Function
 End If 
 For x = 0 To Ubound(vtList)
  For y = (x + 1) To Ubound(vtList)
   On Error Resume Next
   If vtList(x) > vtList(y) Then
    tmpValue = vtList(x)
    vtList(x) = vtList(y)
    vtList(y) = tmpValue
   End If
  Next
 Next 
 BubbleSort = vtList 
End Function

Luckily I could make use of a solution from my colleague Tomas Ekström (his so-called ‘tablewalker’) which made the selection of fields and giving them for the end-user understandable ‘labels’ in the wizard:

export profile form

The next step was creating a dialog between the available ‘Export profiles’ and the Export to Excel solution written by Ken Pespisa.

 dialog for selection source

In order to display the ‘Export profiles’ in the dialoglist I had to re-write Ken’s solution a bit. I advice you to use Ken’s standard solution in stead.

Well, the rest of this export wizard is just following Ken’s work.

 select fields for export dialog

What I tried to achieve with this solution is:

  • having an easy way for an administrator to define ‘Export profiles’ based upon information on Notes forms.
  • presenting an understandable interface for the end-user that enables to create customizable exports to Excel
  • get rid of a large set of nasty Notes views!

A demo you can download here.

Comments (9)

Certification update

While I was attending a technical course for Quickr in Stockholm I reserved some time to upgrade my certification to Notes 7.  My collegue did the test for Notes 8 with the help of CertFX test-software, but to his opinion very little of the questions in the CertFX test came back in the upgrade test. It seems that the main focus on the Notes 8 exam is focussing on composite applications, webservices and design enhancements… so beware for those who have in mind doing the upgrade test with help of the CertFX test-software.

notes certification

Comments (2)

Lotus Quickr education

 Lotus Quickr

I have just attended a 1 1/2 technical course on deploying Lotus Quickr (on Notes or WebSphere), which reminded me some years ago when I was part-time administrator for QuickPlace / Teamroom.

What I lacked was the part that explains how I should setup/create my own templates (based upon LN). So the architectal structure is still not clear for me. Hopefully you know a good source that explains it?

Right now  I am filling my RSS reader with some interesting sources for Quickr, please feel free to post some good additional resources:

http://quickrblog.com/

http://www.projectlounge.com/qblog

My first impression was that the version for Notes is a bit under-developed compared to the WebSphere version…

Update: My collegue Tomas wrote a blog-entry on how to install the Quickr templates provided by SNAPPS:

http://rndnotes.wordpress.com/2007/09/17/installing-snapps-template/

Leave a Comment

Newsletter profile

Currently I am working on a function where users can create a profile for a newsletter. In the profile the user can specify a search query and some options.

It all begins with a simple View Action button:

profile form

The button will check if for the current user already a profile document exists, if so the document will be opened in edit mode, otherwise the form will be opened (the client requested to make all profiles public…)

varUser:=@Name([Abbreviate];@UserName);

@If(
 @IsError(@DbLookup(“”:”NoCache”;”";”v-userprofiles”;varUser;”Tx_DocID”));
  @Do(
   @Command([Compose];”F-PU”)
  );
  @Do(
   @Command([OpenView];”v-userprofiles”;varUser);
   @Command([OpenDocument];”1″)
  )
 )

The form itself is pretty plain and simple. The user can add more criteria to the search query via ‘AND’ or ‘OR’ options. Default we search on only one type of document.

While specifying the criteria, the user sees what he/she is adding to the query:

the profile form

The code behind the ‘ADD’ button is this:

varForm:= “Document”;
varField:=Tx_Fields;
varValues:=@Implode(“\”" + Tx_Values + “\”" ;”:”);

@If(Tx_Option=”AND”;
 @Do(
  varConstructor:= ” & ” +  varField + ” = ” + varValues;
  @SetField( “Tx_Query” ; Tx_Query + varConstructor );
  @SetField( “Tx_LastValue” ; varConstructor )
 );

 @Do(

 @If(@Left(@GetField( “Tx_LastValue” );”)”)=”";
  @Do(
   varPrevValue:= @Right(@GetField( “Tx_LastValue” );”& “);
   varConstructor:=  ” & ( ” + varPrevValue + ” | ” +  varField + ” = ” + varValues + ” )”
  );
 @Do(
  varPrevValue:= @LeftBack(@GetField( “Tx_LastValue” );”)”);
  varConstructor:=  varPrevValue + ” | ” +  varField + ” = ” + varValues + ” )”
 ));
 varNewQuery:= @ReplaceSubstring( Tx_Query; Tx_LastValue ; varConstructor );
 @SetField( “Tx_Query” ; varNewQuery );
 @SetField( “Tx_LastValue” ; varConstructor )
));

@SetField( “Tx_Fields” ; “”);
@SetField( “Tx_Values” ; “”);
@SetField( “Tx_Options” ; “”)

I also added a button so the user can check if the specified query results in any usefull document collection. The code behind this button is:

Sub Click(Source As Button) 
 Dim workspace As New NotesUIWorkspace
 Dim session As New NotesSession
 
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 
 Dim uidoc As NotesUIDocument
 Set uidoc = workspace.CurrentDocument 
 
 searchFormula$ = uidoc.FieldGetText( “Tx_Query” )
 Dim collection As NotesDocumentCollection 
 Set collection = db.Search(searchFormula$, Nothing, 0)
 numDocs% = collection.count
 If numDocs% = 0 Then
  Messagebox “There are no matching documents” , , “Search Result”
  Exit Sub
 Else
  answer% = Messagebox ( (numDocs% & ” document(s) match this query. “), MB_OKCANCEL + MB_ICONQUESTION, “Search Result”)
 End If
End Sub

Because the Newsletter function has to run on a scheduled basis I added some additional options:

  • How often a Newsletter should be sent
  • The number of document links in the Notes Newsletter
  • How old corresponding documents may be

Note: in the timestamp you can add for a search Notes uses the modified date, so this is the date the document has been modified (nice if you working on a test environment with a copy so all the documents ARE modified). You can also add this option as criteria in your search formula ofcourse.

On the bottom of the form I added a button where the user can instantly receive a Notes Newsletter with everything he/she has specified. The code for the button is:

Sub Click(Source As Button) 
 Dim workspace As New NotesUIWorkspace
 Dim session As New NotesSession
 
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 
 Dim uidoc As NotesUIDocument
 Set uidoc = workspace.CurrentDocument  
 Dim doc As NotesDocument
 Set doc = uidoc.Document
 
 searchFormula$ = uidoc.FieldGetText( “Tx_Query” ) 
 maxListSize = uidoc.FieldGetText( “Tx_QueryMax” )
 daysAdjust = doc.Tx_QueryDays(0) 
 Dim dateTime As New NotesDateTime( Now )
 Call dateTime.AdjustDay( -daysAdjust )
 
 Dim collection As NotesDocumentCollection
 Set collection = db.Search(searchFormula$, dateTime, Cint(maxListSize))
 numDocs% = collection.count
 If numDocs% = 0 Then
  Messagebox “There are no matching documents” , , “Search Result”
  Exit Sub
 Else
  answer% = Messagebox ( (numDocs% & ” document(s) found. Creating a Newsletter…”), MB_OKCANCEL + MB_ICONQUESTION, “Search Result”)
  
  Dim newsletter As NotesNewsletter
  Set newsletter = New NotesNewsletter( collection )  
  newsletter.DoSubject = True
  newsletter.SubjectItemName = “Tx_Title”  
  Dim newsletterdoc As NotesDocument
  Set newsletterdoc = newsletter.FormatMsgWithDoclinks( db )  
  newsletterdoc.Form = “Memo”
  newsletterdoc.Subject = “Business Intelligence Newsletter – Your results”
  Call newsletterdoc.Send( False, uidoc.FieldGetText( “Tx_UserName” ))  
  
 End If
End Sub

Some parts of the code above I will re-use in the scheduled agent that sends out the Newsletters on a scheduled base.

Wrap-up: a simple handy function that might save you creating some additional views…

Comments (2)