Only allow compose if no docs exist in view

Use this code if you want to prevent a user from adding more than one document to a view. (1) The code looks to the specified view for an existing document. (2) If document is found, then prompt user to edit that document instead. (3) If no document is found, compose a new document using the specified form.
LotusScript


Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim controldocview As NotesView
Set controldocView = db.GetView("AC")
Dim controldoc As NotesDocument
Set controlDoc = controldocView.GetDocumentByKey( "Timeframe" , True)    
	
If controlDoc Is Nothing Then
	Dim uidoc As notesuidocument   
	Set uidoc = workspace.ComposeDocument( "", "", "TF" )
Else
	Msgbox "A Timeframe doc already exists." & Chr(10) & Chr(10) & "Please update this doc instead.", 0 + 64 , "Invalid Function"
End If
	

Posted by fbrefere001 on Tuesday February 26, 2002