LOTUSSCRIPT/COM/OLE CLASSES
Examples: QuerySave event
1. This script prevents the user from saving the current document if there is nothing in the Title field. It displays a message and moves the insertion point to the Title field.
Sub Querysave(Source As Notesuidocument, _
Continue As Variant)
If ( source.FieldGetText( "Title" ) = "" ) Then
Messagebox( "You must enter a title." )
Call source.GotoField( "Title" )
continue = False
End If
End Sub
2. This script checks the contents of the dueDate field when the user tries to save the current document, and updates the ProjectStatus field accordingly. If the dueDate is less than four days away, it puts "Urgent" into the ProjectStatus field; if it's less than six days away, it puts "Hurry up a little" into the field; if it's six or seven days away, it puts "No worries" into the field.
Sub Querysave(Source As Notesuidocument, _
Continue As Variant)
Dim targetDate As String
Dim todayDateTime As NotesDateTime
Dim dueDateTime As NotesDateTime
Dim daysLeft As Long
Call source.Refresh
Set todayDateTime = New NotesDateTime( "Today" )
Set dueDateTime = New NotesDateTime _
( source.FieldGetText( "dueDate" ) )
daysLeft = ( dueDateTime.TimeDifference _
( todayDateTime ) ) / 86400
Select Case daysLeft
Case 1, 2, 3:
status = "Urgent"
Case 4, 5, 6:
status = "Hurry up a little"
Case 6, 7:
status = "No worries"
End Select
Call source.FieldSetText( "ProjectStatus", status )
End Sub
See Also
QuerySave event
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary