Manage Learn to apply best practices and optimize your operations.

How to make Notes view icons run code

In Notes/Domino 6 the InViewEdit method allows developers to programmatically make columns in views editable. This tip brings that functionality a step further and makes icons in views active.

In R6, there is a new method in views called "InViewEdit". This method allows you to programmatically make columns in views editable. If you want to make icons in views active so when you click on it, they perform some code, use this tip.

I have use this principle to run many other functions, like launching Dom.doc folders, opening dialog boxes, or even launching a Web site address. Use the programmatic name and the Columnvalue to further expand your options on what action to execute. Use Script libraries to make the same actions available in multiple views.

First, open the properties of a column, and turn on "Display values as Icon" and "Editable Column". Then, change the programatic name of the column to "LaunchAtt". In the column formula, add this formula:@If(@AttachmentNames!="";5;"")

Finally, in the lnViewEdit method, throw in this code:

Sub Inviewedit(Source As Notesuiview, 
Requesttype As Integer, Colprogname As Variant, 
Columnvalue As Variant, Continue As Variant)
  Const SAVE_REQUEST = 3
 Dim session As New NotesSession
 Dim workspace As New NotesUIWorkspace
 Dim dbCurrent As NotesDatabase
 Dim docCurrent As NotesDocument
 Dim  varFormulaAttachments As String
 Dim varAttachments As Variant
 Dim varSelect As Variant
 Dim strPath As String
 Dim strAction As String
 Set dbCurrent = Session.CurrentDatabase
 Select Case RequestType
  Set docCurrent = 
  Select Case Colprogname(0)  
' Programatic name of the column
  Case "LaunchAtt"    
' User clicked the icon to see attachments.
   Continue = False
   '-- Select the attachment
   varSelect = workspace.Prompt
 "Select from the following list of attachments", "
" , varAttachments)
   '-- Proceed to detach file
   If varSelect = "" Then Exit Sub
   strFileNameDetach = varSelect
  Case Else
   '-- you can do other actions such as 
save documents, see the R6 Help for details.
  End Select
 End Select
 Exit Sub
 '-- Load the attachments in a variant
 varFormulaAttachments = |@AttachmentNames| 
 varAttachments = 
Evaluate(varFormulaAttachments, docCurrent)
 '-- Detach the file that is requested.
 Forall item In docCurrent.Items
  If ( item.Name = "$FILE") Then  
   Set object =
   If Not (object Is Nothing) Then 
    strFileName =   Object.Name
    If strFileName =  strFileNameDetach Then 
     Call  Object.ExtractFile
( strPath  & ""& strFileName)
    End If
   End If
  End If 
 End Forall
 filePath = strPath + "/" +  strFileNameDetach
 filePath ="file://" + filepath
 Print Filepath
 Call Session.SetEnvironmentVar
 Call  workspace.urlopen(filepath)
 '-- Get the Temp Path and append 
My Documents and My Downloads
 strPath = Environ("Temp")
 strPath = Strleft(strPath,"LOCALS",0)+
"My DocumentsMy Downloads"
 If Dir(strPath, 16 )="" Then
  Print "Creating directory: " & strPath
  Mkdir strPath
  Print "Using directory " & strPath 
 End If 
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Jose Zaldivar. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our bimonthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on Lotus Notes Domino Agents



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...