Hey All,
I have a querySave event defined below and it makes a call to a form function createHistoryEntry also defined below.
My problem is, eveytime I edit and close the form, it creates a conflict doc instead of creating the entry and saving. I thought that query save code executed before the doc was actually written to disk?
Thanks,
Shawn
Sub createHistoryEntry(prfDocument As NotesUIDocument)
' Created by Shawn Taylor on October 13, 2006. This sub tracks the document editors over time
' This will give people a reference as to who edited the document and when in case follow up or clarification is needed
' ________________________________________________________________________________________________________
' Edited on October 25, 2006 commented out the created on line in lieu of the edited on line in the first part of the
' if statement that determines the content of the current edit history.
' ________________________________________________________________________________________________________
' Create variables used for edit history
Dim session As New NotesSession
Dim editHistory As String
Dim currentEdithistory As String
Dim currentDoc As NotesDocument
Set currentDoc = prfDocument.Document
' prfDocument.EditMode = True ' open the doc for editing
' editHistory = prfDocument.FieldGetText("fieEditHistory") ' retrieve the current history
' prfDocument.FieldClear("fieEditHistory") ' clear the field of the current entry
editHistory = currentDoc.fieEdithistory(0)
currentDoc.fieEdithistory = "" ' clear the field of the current entry
If editHistory = "" Then 'Defines creating or editing and sets string accordingly
' currentEdithistory = "Created on " + Date$ + " at " + Time$ + " by " + s.CommonUserName ' create the string we want in the creator field
currentEdithistory = "Edited on " + Date$ + " at " + Time$ + " by " + session.CommonUserName ' create the string we want in the creator field
Else
currentEdithistory = ",Edited on " + Date$ + " at " + Time$ + " by " + session.CommonUserName ' create the string we want in the creator field
End If
editHistory = editHistory + currentEdithistory ' Make comma seperated string for edits field
currentDoc.fieEditHistory = editHistory
' prfDocument.FieldAppendText("fieEdithistory", editHistory) ' Insert above string to field - fieBroEdit History
' prfDocument.Save ' save our edit history
' prfDocument.EditMode = False ' close the doc
session.close ' close the session
End Sub
Sub Querysave(Source As Notesuidocument, Continue As Variant)
' The purpose of this event is to mark a new note with the readers field data required to web enable the PRF.
' That is accomplished by creating a variable of our custom data type 'ProblemReportForm' and executing the method
' setReaderfield.
' If the doc is not a new document, we then set a flag for notification based on field level changes that are visible to the customer
' and the current notification status.
' Declare session variables
Dim session As New NotesSession
Dim db As NotesDatabase
Dim currentPrfDoc As NotesDocument
Dim thisTrnaPrf As New ProblemReportForm
Dim serverName As NotesName
' Set session parameters
Set db = session.currentDataBase
Set currentPrfDoc = Source.Document
Set serverName = session.CreateName(Cstr(db.server))
' Here we are checking to see if a conflict document exists. If it does, we tell the user about the problem and exit the sub
If Source.Document.HasItem("$Conflict") Then
Msgbox "This is a [Replication or Save Conflict] document. Changes should only be made to the original document! Call X300 if you need help. "
Exit Sub
End If
' We are checking to see if hte document has been saved. If it has not been saved we web enable the document by setting
' the readers field with the customer ID, and our internal ID's
If ( currentPrfDoc.IsNewNote ) Then
Call thisTrnaPrf.setReaderField(db, currentPrfDoc)
Else
If (currentPrfDoc.SendCustMail(0) = True) And (currentPrfDoc.EmailNotificationFlag(0) <> "False") Then
currentPrfDoc.EmailNotificationFlag = "False"
End If
End If
' Call currentPrfDoc.Save(False, False) ' saves the changes
Call session.close ' end current session
' This function writes an edit stamp to the document
Call createHistoryEntry(source)
End Sub