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.