Home > Domino Tips > Developer > Domino > Autoclosing a document
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

Autoclosing a document


George Savery
08.25.2003
Rating: -3.33- (out of 5)


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


View expert feedback to this tip.

I had a customer who requested that a document be automatically closed by the system. To do this, I used the Notes Timer (and a field in the DBProfile) so users can change the timeout interval.

Code

I created a subform called TimerSF.

Single Field "DocTimeout"
Computed Number 
@Text(@GetProfileField( "DBProfile" 
; "DocTimeout"));


Declarations
Dim elapsedTime As Integer
Dim elapsedTimer As NotesTimer
%INCLUDE "lsconst.lss"

Sub Postopen(Source As 
Notesuidocument)
 Dim backdoc As notesdocument
 Set backdoc = source.Document
 Set elapsedTimer = New NotesTimer
(60, "Elapsed time since opening document")
 elapsedTime = 0
 On Event Alarm From elapsedTimer 
Call elapsedTimerHandler
 If backdoc.docTimeout(0) = "" 
Or Cint(backdoc.docTimeout(0)) = 0 Then
  elapsedTimer.Enabled = False
  Print "Timer Disabled"
 Else
  elapsedTimer.Enabled = True
  Print "Timer Enabled"
 End If
 
End Sub

Sub Postrecalc(Source As Notesuidocument)
 elapsedTime = 0
 'Reset Counter if doc is being edited
End Sub

Sub elapsedTimerHandler
(Source As NotesTimer)
 Dim workspace As New NotesUIWorkspace
 Dim uidoc As NotesUIDocument
 Dim backdoc As notesdocument
 Set uidoc = workspace.CurrentDocument
 Set backdoc = uidoc.Document 
 elapsedTime = elapsedTime + 1
 If elapsedTime > Cint(backdoc.
DocTimeout(0)) Then
  Call uidoc.Save  
  Call uidoc.Close
  Print "Doc Closed as Timeout period Expired"
 Else
  Print Cstr(backdoc.DocTimeout(0)) + " 
< " + Cstr(elapsedTime)
 End If
End Sub

EXPERT FEEDBACK TO THIS TIP

  1. Don't use a field on the form for loading the profile value -- do it in the code and store the value in a global. More efficient and hack-proof.

  2. If you do use a field, at least make it Computed for Display -- there's no need to store this value.

  3. Don't save changes to a document without first checking whether it's in edit mode.

  4. Are we really sure we want to save changes without prompting the user?

  5. This may crash the user's workstation in the following scenario: UIdoc.save fails because of input validation. Messagebox with validation error message. User doesn't click OK within the interval to the next timer event (one minute). Notes crashes because the timer event happens when the previous timer event isn't done yet. To prevent this, the code should disable the timer before doing anything that might prompt the user.

  6. Timer event uses NotesUIDocument.CurrentDocument -- this returns the current document that's open onscreen. Since the user can open additional windows, the timer document may be open but not be the current window. The event code may therefore save and close a document in another window that it wasn't meant to mess with.

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


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.




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



RELATED CONTENT
Domino
Mimic Lotus Notes Domino application functionality on the Web
A single form to view and edit any Lotus Notes document
DECS and DCR external data access considerations
How to create non-scrolling Lotus Domino view headers on the Web
Disabling the 'Submit' button on a form
An easier way to update a rich text field
Results from Default Notes Search have # of responses in brackets
Lotus Notes/Domino veteran offers comprehensive list of app dev tools
Notes to XML. . .and back again
Creating thumbnail images using LS2J in LotusScript

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