Saving.. but I don't see why

I have the following validation function for a richtext field…

Function validatert(doc ,uidoc,body) As Boolean

Dim hasInfo As String

Dim i As Integer

Dim rtnav As NotesRichTextNavigator

Dim elemType(1 To 8) As Long

Dim tempDoc As NotesDocument

Call uidoc.refresh(True)

Set doc = uidoc.document

Set body = doc.GetFirstItem("Body")

Set rtnav = body.CreateNavigator

Dim rtrange As NotesRichTextRange

Set rtrange = body.CreateRange

elemType(1) = RTELEM_TYPE_DOCLINK

elemType(2) = RTELEM_TYPE_FILEATTACHMENT

elemType(3) = RTELEM_TYPE_OLE

elemType(4) = RTELEM_TYPE_SECTION

elemType(5) = RTELEM_TYPE_TABLE

elemType(6) = RTELEM_TYPE_TABLECELL

elemType(7) = RTELEM_TYPE_TEXTPARAGRAPH

elemType(8) = RTELEM_TYPE_TEXTRUN

For i = 2 To 8 Step 1

	If rtnav.FindFirstElement(elemType(i)) Then

		hasinfo = "Yes"

		Exit For

	Else

		hasinfo = "No"

	End If

Next

If hasinfo = "No" Then

	

	Messagebox "Please enter comments.",16,"Required field"

	

	Call uiDoc.FieldClear("Body")

	Call uiDoc.gotofield("Body")

	validatert = False

	Exit Function

Else

	Dim item As NotesItem

	Dim plainText As String

	Set item = doc.GetFirstItem( "Body" )

	plainText = item.Text

	

	Dim session As New NotesSession

	Dim db As NotesDatabase

	Dim setupDoc As NotesDocument

	Set db = Session.CurrentDatabase

	Set setupDoc = db.GetProfileDocument("Setup")

	

	If doc.Type(0) = "Standard" Then

		If setupDoc.CommentText(0) = "" Then

		Else

			If plainText = setupDoc.CommentText(0) Then 

			Else

				Dim answer As Integer

				Dim messagetext As String

				messagetext = "You changed the standard comment the system supplied, but the log type remained set to Standard!" 

				messagetext = messageText & Chr(13) & Chr(13) & "You will need to change the Log Type from Standard to keep the comments you have changed."

				Messagebox messagetext,16,"Validation Error"

				validatert = False

				Exit Function

			End If

		End If

	End If

End If

validatert = True

End Function

I have richtext field called “Body”

when a new document is creted, it gets set with standard text in it…

If a user tries to save a document, with the type field set to standard, but changes the comment…

I give them a validation error… telling them to change the type…

At this point the document hasn’t been saved…

The user hits the cancel button, which has the following:

Field SaveOptions := “0”;

@Command([FileCloseWindows])

somehow, the document is saved and now comments other than the standard are entered…

I walked through the debugger, and I kept checking for source

and then document and then isnewNote = false… but never saw it…

I think it has something to do w/this line:

Call uidoc.refresh(True)

But not sure…

My querysave has the following:

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim doc As NotesDocument

Dim Session As New NotesSession

Set doc = source.document

Dim fName As NotesName

Set fName = New NotesName(doc.GetItemValue("From")(0))

If doc.StatNum(0) > 1 Then

Else

	If fName.Canonical = Session.UserName Then

		If ValidateDoc(doc, Source) Then

		Else

			Continue = False

			Exit Sub

		End If

	End If

End If	

End Sub

And the function that calls the validatert function is the following:

Function ValidateDoc(Doc As NotesDocument, UiDoc As NotesUIDocument) As Boolean

Dim Body As NotesRichTextItem

With doc

	If .Type(0) = "" Then

		Messagebox "Please select the Type.",16,"Required Field Selection"

		Call uidoc.GotoField("Type")

		ValidateDoc = False

		Exit Function

	End If

	

	If .EmpName(0) = "" Then

		Messagebox "Please select the Employee Name.",16,"Required Field Selection"

		Call uidoc.GotoField("EmpName")

		ValidateDoc = False

		Exit Function

	End If

	

	If .WED(0) = "" Then

		Messagebox "Please select the Week Ending Date.",16,"Required Field Selection"

		Call uidoc.GotoField("WED")

		ValidateDoc = False

		Exit Function

	End If

	

	

End With



If  Not validatert(doc ,uidoc,body) Then

	ValidateDoc = False

	Exit Function

End If



ValidateDoc = True

End Function

This is called from querysave, then that calls the validatert function.

I don’t see a save anywhere… yet my document is being saved.

Any ideas would be greatly appreciated…

Subject: Saving… but I don’t see why…

You say:“This is called from querysave, then that calls the validatert function. I don’t see a save anywhere… yet my document is being saved.”

…I am a bit confused. If your script is called from the QuerySave event, and you don’t set the flag “Continue = False” somewhere whithin that script, then the normal process continues, which is… saving the document.

QuerySave script is ran before saving.

I am not sure if this is the answer you were looking for - or am I missing something?

Cheers,

Nicolas Abesdris

Quintessence e-solutions Inc.

Subject: RE: Saving… but I don’t see why…

Well in the query save…

I call

If ValidateDoc(doc, Source) Then

Else

Continue = False

Exit Sub

The function is returning false

and Querysave stops…

but the document is still saved…