Home > Domino Tips > Developer > How to make Notes view icons run code
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

QUICKTIPS

How to make Notes view icons run code


Jose Zaldivar
10.10.2005
Rating: -3.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Agent
Run or restart Notes/Domino agents via text messages
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax

QuickTips
View hidden fields on Lotus Notes/Domino forms
A bevy of Notes/Domino development tips
How to protect your Lotus Notes application design
Merging views
Stop an agent without shutting down the Amgr task
Collapsing outlines
Find all databases associated with a template
Verifying user's date setting and time zone on local PC
Load design for a single database
Options for changing passwords

Lotus Notes Domino Agents
How the Agent Profiler tool improves Notes/Domino performance
Run or restart Notes/Domino agents via text messages
Calculating results for a column in a Lotus Notes view
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Top 10 Lotus Notes/Domino coding and development tips of 2008
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
Top 10 Lotus Notes Domino programming and development tips of 2007

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts