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