Subject: Found some code
I have done this before and can’t find my code. The basic concept isEnter the field and grab the value.
OnChange or on exit, compare the initial and final and build your email message if the value is different.
If I can find the code I’ll post it.
But seriously, Audit Manager just takes care of it for you. You need to add a dll to the server and update the server’s ini file but once that’s done, the audit happens at the server level so user’s can’t bypass the code. It’s freaking sweet and should be part of the Domino core functionality.
This is wicked old (from '97 actually) but it works. I think the onChange may provide an easier way to manage this but I just can’t find an example yet.
I found this in the Notes User Discussion website (credit to Kevin Loftis);
In the (Declarations) event of the field:
Dim tPreviousValue As String
In the Entering event:
tPreviousValue = nUIDoc.FieldGetText ( “YourFieldName” )
In the Exiting event:
Dim tCurrentValue As String
tCurrentValue = nUIDoc.FieldGetText( “YourFieldName” )
If Trim$( tPreviousValue ) <> Trim$( tCurrentValue ) Then
Do your stuff
End If
<edit 2>
OK, I found my ‘onChange’ code and it will work for your needs. Note that the field’s initial value is trapped by the form’s QueryOpen event. The code below is used to revert the field to the original value if a reason for the change isn’t entered by the user but you can adapt this to send an email with the ‘from/to’ values.
Enjoy!
Sub Onchange(Source As Field)
'initReminderDate set by form QueryOpen event
Dim s As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim newDueDate As String
Dim Reason As String
Dim CRLF As String
CRLF = Chr(13) & Chr(10)
Set uidoc = workspace.CurrentDocument
newDueDate = Cstr(uidoc.FieldGetText("VerifyReminderDueDate"))
If initReminderDate <> "" Then
Reason = Inputbox$ ( "Please enter a justification for extending the verification completion date." , "Justification?" )
If Reason = "" Then
Messagebox "Sorry, you must enter a reason, reminder date is reverted to: " & initReminderDate
Call uiDoc.FieldSetText("VerifyReminderDueDate", initReminderDate)
Call uiDoc.Refresh
Exit Sub
Elseif Reason <> "" Then
If uidoc.FieldGetText("VerificationExtensionJustify") = "" Then
Call uidoc.FieldAppendText("VerificationExtensionJustify", "[Extension granted on: " & Cstr(Now) & _
" by: " & s.CommonUserName & ": " & Reason & "] ")
Else
Call uidoc.FieldAppendText("VerificationExtensionJustify",". " & CRLF & "[Extension granted on: " & Cstr(Now) & _
" by: " & s.CommonUserName & ": " & Reason & "] ")
End If
Else
'do nothing - it's the initial setting of the due date so no reason is required.
End If
End If
End Sub