Autosave A Document

Mobile users sometimes complain that they have lost their input data because their laptop shut down while composing a long Notes document. This is a LotusScript routine that allows user's to automatically save thier documents, e-Mail or otherwise. Step 1 - Add the following definitions to the Declarations: Dim timeKeeper As Integer Dim timeClock As NotesTimer Dim autoSaveInterval As Integer Step 2 - Paste the following code into the...

Postopen and PostModeChange events: Dim session As New NotesSession Dim autoSaveMinutes As Integer If Source.EditMode = True Then AutoSaveOn = session.GetEnvironmentString( "AutoSaveOn" ) ' Is AutoSave turned on in the user's notes.ini file? If (AutoSaveOn <> "1") Then If (AutoSaveOn = "0") Then Print "AutoSave feature is off" End If Exit Sub ' AutoSave is not turned on - Leave End If autoSaveValue = session.GetEnvironmentString( "AutoSaveInterval" ) ' What is the AutoSave time increment set to in the user's notes.ini file If autoSaveValue = "" Then autoSaveValue = "1800" ' An AutoSave time increment was not found - Use the default of 30 minutes End If autoSaveInterval = Cint( autoSaveValue ) ' Inform the user how frequently his/her doc will be saved autoSaveMinutes = autoSaveInterval/60 If autoSaveMinutes > 0 Then Print "AutoSave feature activated for every " & autoSaveMinutes & " minutes..." Else Print "AutoSave feature activated" End If Set timeClock = New NotesTimer(1, "Elapsed time since opening document") ' Activate the timer timeKeeper = 0 On Event Alarm From timeClock Call elapsedTimerHandler End If Step 3 - Add this new function: Sub TimeClock(Source As NotesTimer) On Error Resume Next timeKeeper = timeKeeper + 1 If timeKeeper = autoSaveInterval Then ' The AutoSave time increment has been met - Save this doc Dim Workspace As New NotesUIWorkspace Dim UIDoc As NotesUIDocument Set UIDoc = Workspace.CurrentDocument Call UIDoc.Save Print "Saving document... " timeKeeper = 0 End If End Sub Step 4 - Paste the following code into an agent or SmartIcon: REM " Let the user turn AutoSave On or Off?" AutoSaveVal := @Prompt([OKCANCELCOMBO]; "Change Auto Save Settings"; "Turn on/off Auto Save?"; ""; "On" : "Off"); @If(AutoSaveVal = "0"; @Return(NULL); AutoSaveVal = "On"; @Environment( "AutoSaveOn"; "1"); AutoSaveVal = "Off"; @Environment( "AutoSaveOn"; "0"); NULL); REM "Let the user set the AutoSave time increment" ASValue := @Prompt([OKCANCELCOMBO]; "Change Auto Save Settings"; "Select an Auto Save time interval:):"; "Every 15 minutes"; "Every 5 minutes" : "Every 10 minutes" : "Every 15 minutes" : "Every 20 minutes" : "Every 25 minutes" : "Every 30 minutes"); @If(ASValue = "0"; @Return(NULL); ASValue = "Every 5 minutes"; @Environment("AutoSaveInterval"; "300"); ASValue = "Every 10 minutes"; @Environment("AutoSaveInterval"; "600"); ASValue = "Every 15 minutes"; @Environment("AutoSaveInterval"; "900"); ASValue = "Every 20 minutes"; @Environment("AutoSaveInterval"; "1200"); ASValue = "Every 25 minutes"; @Environment("AutoSaveInterval"; "1500"); ASValue = "Every 30 minutes"; @Environment("AutoSaveInterval"; "1800"); "") NOTE: The timer 'alarm' event triggers every second, and the event code does nothing 99.9% of the time. Instead, the timer interval should be set equal to the save interval, so there are no unnecessary executions. You should print that you're attempting save before actually doing so. Also note that the attempt to save may cause sudden validation errors to pop up in the middle of editing.

This was first published in November 2000
This Content Component encountered an error



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:




  • 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 ...