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
 Case SAVE_REQUEST
  Set docCurrent = 
dbCurrent.GetDocumentByID(source.caretnoteid)
  Select Case Colprogname(0)  
' Programatic name of the column
  Case "LaunchAtt"    
' User clicked the icon to see attachments.
   Continue = False
   Gosub SETWORKINGDIR 
   Gosub LOADATTACHMENTS
   '-- Select the attachment
   varSelect = workspace.Prompt
( PROMPT_OKCANCELLIST, "LAUNCH ATTACHMENT",
 "Select from the following list of attachments", "
" , varAttachments)
   '-- Proceed to detach file
   '--
   If varSelect = "" Then Exit Sub
   strFileNameDetach = varSelect
   Gosub DETACHFILE
   Gosub LAUNCHFILE 
  Case Else
   '-- you can do other actions such as 
save documents, see the R6 Help for details.
  End Select
 End Select
 Exit Sub
 
LOADATTACHMENTS:
 '-- Load the attachments in a variant
 varFormulaAttachments = |@AttachmentNames| 
 varAttachments = 
Evaluate(varFormulaAttachments, docCurrent)
 Return
 
DETACHFILE:
 '-- Detach the file that is requested.
 Forall item In docCurrent.Items
  If ( item.Name = "$FILE") Then  
   Set object =
docCurrent.GetAttachment(item.Values(0))
   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
 Return
 
 
LAUNCHFILE:
 filePath = strPath + "/" +  strFileNameDetach
 filePath ="file://" + filepath
 Print Filepath
 Call Session.SetEnvironmentVar
("URLOPEN",filePath)
 Call  workspace.urlopen(filepath)
 Return
SETWORKINGDIR:
 '-- 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
 Else
  Print "Using directory " & strPath 
 End If 
 Return
End Sub

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

This tip was submitted to the SearchDomino.com 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.

This was first published in October 2005

Dig deeper on Lotus Notes Domino Agents

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close