Trouble with SaveOptions
Posted on 2006-04-04
Having some trouble with my saving on a doc I have the code below in the SaveOptions field. I also have a validation on the exiting of the username field to make sure the user has not already started a version of this doc before. Now when it runs the script and validates that this would be a duplicate, it closes the form but it saves a copy anyways. How can I tweak these 2 to validate properly but not save the duplicate.
Code in Saveoptions field:
@If(@IsNewDoc ; "1" ; "0")
Exiting code in username field:
Sub Exiting(Source As Field)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim username As String
Dim ndoc As NotesDocument
Dim cdoc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set ndoc = uidoc.Document
Set view = db.GetView("(completed)")
username = uidoc.FieldGetText( "username")
key = username
Set cdoc = view.GetDocumentbyKey(key)
If cdoc Is Nothing Or cdoc.NoteID= ndoc.NoteID Then
Msgbox "You have already started a Self-Assessment, please edit that version."
Set doc = uidoc.Document
doc.SaveOptions = "0"