Archive for May, 2007

Creating a ‘context-sensitive’ help (Notes client)

Mostly providing a help function in a database is a step that comes long after an application has been put ‘live’.

In order to save myself a lot of design additions I created a context-sensitive ‘help’ function for application managers so they can add them later, when users come with the need for documentation.

The function I add on view- and formlevel wherever I think it might be handy in the future and is really easy to implement.

On a view or a form I add an action button with some @formula code.

On a view:

db:=@Subset(@DbName; -1);
@If(@IsError(@DbLookup(“”:”NoCache”;”"; “(Help)”; @ViewTitle+”\\”+db;1));
@If(@IsMember(“[Admin]“;@UserRoles);
@Do(
 @Set(“tmpval”;@Prompt([YesNo];”Help module”;”There is no help for this view available. Would you like to create a new Help document?”));
 @If(tmpval;@Command([ToolsRunMacro];”(CreateHelpView)”);”"));
@Prompt([Ok];”Help module”;”There is no help for this view available.”));
@Command([OpenHelpDocument]; “”; “(Help)”; @ViewTitle+”\\”+db))

On a form:

db:=@Subset(@DbName; -1);
@If(@IsError(@DbLookup(“”:”NoCache”;”"; “(Help)”; Form +”\\”+db;1));
@If(@IsMember(“[Admin]“;@UserRoles);
@Do(
 @Set(“tmpval”;@Prompt([YesNo];”Help module”;”There is no help for this form available. Would you like to create a new Help document?”));
 @If(tmpval;@Command([ToolsRunMacro];”(CreateHelpDoc)”);”"));
@Prompt([Ok];”Help module”;”There is no help for this form available.”));
@Command([OpenHelpDocument]; “”; “(Help)”; Form+”\\”+db))

If a user has the role Admin assigned it will enable to create a new ‘Help’ document for this particular design element.

If there is no ‘Help’ document available for this design element a popup window will appear:

help popup

When selecting ‘No’ the code will stop. When selecting ‘Yes’ an agent will run and creates the document on the background. A confirmation will appear:

help confirm

If the user hits the action button again the newly created document will appear in a new window, just like the normal client Help function would do. This enables the user to switch between the application and the ‘Help’ document.

If you add the Admin role in an Authors field on the ‘Help’ document they can edit the document via a double-click and add content to the document.

At least this function saved me a lot of time and surprised application managers that it was already there from scratch!

Here is the code for the agent:

Sub Initialize
%REM
———————————————————————————————————————
The next script runs when there is no help document available for this design element
The script will create a new help document
———————————————————————————————————————
%END REM
 Dim Session As New NotesSession
 Dim workspace As New NotesUIWorkspace
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 Dim lookupview As NotesView 
 Dim uidoc As NotesUidocument
 Dim thisdoc As notesdocument
 Dim lookupdoc As notesdocument
 Dim kolldoc As notesdocument
 Dim kollview As notesview
 Dim newhelpdoc As notesdocument
 Set uidoc = workspace.CurrentDocument
 Set thisdoc = uidoc.Document
 Dim helpform As String
 Dim server As String
 Dim path As String
 
 path = db.FilePath
 helpform=thisdoc.Form(0)
 
 ’Collect data from help view
 Set kollview = db.GetView( “(Help)” )
 key$ = helpform+” “+path
 Set kolldoc = kollview.getdocumentbykey(key$, True)
 If  kolldoc Is Nothing Then
  
  ’Create a new help document
  Set newhelpdoc = db.CreateDocument
  newhelpdoc.form=”F-Help”
  newhelpdoc.Tx_About=”Instructions for: ” + helpform
  newhelpdoc.Tx_Databas=path
  newhelpdoc.Tx_Form=helpform
  saveres = newhelpdoc.save(True,True)
  If saveres Then
   var = Messagebox(“A help document has been created in the Help module.”+Chr(10)+Chr(10)+”Please test the connection via the Help button.”,0+64,”Help module”)
  Else
   var = Messagebox(“A Help document could not be created. Please check the connection to the Help module.”,0+16,”Help module”)
  End If
 Else 
  var = Messagebox(“A Help document already exists for this form.”,0+16,”Help module”)
 End If    
 
End Sub

Comments (3)