If document doesn't exist!
If document doesn't exist!
(OP)
Hello all,
I am trying to write a LotusScript that will:
1. Look in the database to see if a document exists by checking a field for a value (Collected by a inputbox)
2. if the document exists - exit the sub
3. if there is NO Document - continue.
Any suggestions?
Thanks,
la
I am trying to write a LotusScript that will:
1. Look in the database to see if a document exists by checking a field for a value (Collected by a inputbox)
2. if the document exists - exit the sub
3. if there is NO Document - continue.
Any suggestions?
Thanks,
la
RE: If document doesn't exist!
Dim searchstring$
Dim coll As Notesdocumentcollection
Dim session As New Notessession
Dim db As Notesdatabase
' suppose your db is the current db
Set db=session.Currentdatabase
searchstring$=Inputbox(" ... ' You know this function
' Trimming extra spaces
searchstring$=Trim$(searchstring$)
If Not searchstring$="" Then
Set coll=db.Search(|fieldname="|+searchstring+|"|,0)
If coll.Count>0 Then
' ...continue here
End If
Else
Msgbox "Interrupted by user!"
End If
Remember: db.Search can be too slow for your need, create a sorted view on field fieldname and populate the collection with:
Set coll=view.getalldocumentsbykey(searchstring$,True)
where view is a Notesview object created by:
Set view=db.Getview("viewname")
the last boolean param can be set to False if you don't need an exact match.
If you are looking for a single document try to use Getdocumentbykey, in this case you don't need a document collection saving resources.
Hope will be helpful.