Checks if field value has been changed on entering/exiting form

This script will, upon entering, place the field value in a variable, then upon exiting place the current value in another variable. If the two values are the same no action is taken, if they are different, take action.
Lotus Notes Form • LotusScript

(Declarations)

Dim valuein As Variant
Dim valueout As Variant


Sub Entering(Source As Field)
     
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = workspace.CurrentDocument
     Set Currentdoc= uidoc.Document     
     valuein = uidoc.FieldGetText( "fieldname" )
     
End Sub


Sub Exiting(Source As Field)
     
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = workspace.CurrentDocument
     Set Currentdoc= uidoc.Document     
     valueout = uidoc.FieldGetText( "fieldname" )
     Dim doc As NotesDocument
     Set doc = uidoc.Document  
     
     If Not valueout = "" Then
          If valuein = valueout Then
                    ' Value has not changed and do nothing
          Else
                    ' Value has changed and change other field value
               Currentdoc.otherfield="newvalue                                                 ' UIDOC reference
               doc.co_notifyon = doc.co_anotifydate(0)                                     ' DOC reference
          End If
                              
          Call uidoc.refresh
          
     End If    
     
End Sub

Posted by fbrefere001 on Tuesday July 3, 2001