Hello, I have created response documents in the querysave event of the form, then I want to delete main and response documents on the view, there is an error message"Note Error: No document were categorized".
Anyone can help me to figure out what 's the wrong with the coding below?It only assigned the main document “Y”, does not aggign “Y” to the response documents.
While Not(doc Is Nothing)
doc.SoftDelete= "Y"
Call doc.Save( False, True )
Set dc=doc.Responses
Call dc.StampAll("SoftDelete","Y")
Set doc = collection.GetNextDocument(doc)
Wend
Here is the coding on the querysave event of the form
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim uidoc As NotesDocument
Dim akey As String
Dim ndoc As NotesDocument
Dim item As NotesItem
Dim dc As notesdocumentcollection
Set db=s.CurrentDatabase
Dim doc1 As NotesDocument
Set doc1= Source.document
If Source.IsNewDoc Then
If doc1.ResourceName ( 0 )="" Then
Messagebox " Please click available button and choose a resource."
Call source.GotoField( "ResourceName" )
Continue = False
Exit Sub
End If
If doc1.sDate ( 0 )>doc1.eDate(0) Then
Messagebox " End date must be laterr than start date."
Call source.GotoField( "eDate" )
Continue = False
Exit Sub
End If
Set item = source.document.GetFirstItem( "repeat" )
Forall v In item.Values
Set view=db.getview("LookUp")
'akey=source.Document.ResourceName(0)+Str(source.Document.calendarDate(0))
akey=source.Document.ResourceName(0)+v
Set doc=view.GetDocumentByKey(akey)
If Not doc Is Nothing Then
Messagebox "The date " + v+ " was booked"
Continue=False
Exit Sub
Else
Set ndoc=db.CreateDocument
ndoc.form="Reservation"
ndoc.ReservedBy=doc1.ReservedBy(0)
ndoc.sDate=doc1.sDate(0)
ndoc.eDate=doc1.eDate(0)
ndoc.calendarDate=Cdat(v)
ndoc.repeat=doc1.repeat
ndoc.SoftDelete=doc1.SoftDelete(0)
ndoc.ResourceName=doc1.ResourceName(0)
ndoc.Description=doc1.Description(0)
Call ndoc.MakeResponse( doc1 )
Call ndoc.Save( False, True )
End If
End Forall
Messagebox "The new reservation has been created. "
End If
If Not Source.IsNewDoc Then 'if edit old UIDOC
If Cstr(doc1.sDate(0)) <>StartDate Or Cstr(doc1.eDate(0)) <>EndDate Then
Set dc= doc1.Responses
Call dc.RemoveAll(True)
'after deletion, create new docs
Set item = source.document.GetFirstItem( "repeat" )
Forall v In item.Values
Set ndoc=db.CreateDocument
ndoc.form="Reservation"
ndoc.ReservedBy=doc1.ReservedBy(0)
ndoc.sDate=doc1.sDate(0)
ndoc.eDate=doc1.eDate(0)
ndoc.calendarDate=Cdat(v)
ndoc.repeat=doc1.repeat
ndoc.SoftDelete=doc1.SoftDelete(0)
ndoc.ResourceName=doc1.ResourceName(0)
ndoc.Description=doc1.Description(0)
Call ndoc.MakeResponse( doc1 )
Call ndoc.Save( False, True )
End Forall
Messagebox "Reservation has been changed."
Else
Set dc= doc1.Responses
Call dc.StampAll("ResourceName", doc1.ResourceName(0))
Call dc.StampAll("Description",doc1.Description(0))
Call dc.StampAll("ReservedBy",doc1.ReservedBy(0))
Messagebox "Reservation has been changed."
End If
End If
Call ws.ReloadWindow( )
End Sub
here is the coding on the button of the view
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New notesUIWorkspace
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim num As String
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
If collection.count=0 Then
Messagebox "Please select a document to delete.",0+48+0,"Attention!"
End
End If
askme = ws.Prompt(PROMPT_YESNO, "Deletion", "Are you sure to delete the reservation?")
If askme = 0 Then
Messagebox "Deletion has been cancelled"
Exit Sub
End If
While Not(doc Is Nothing)
doc.SoftDelete= "Y"
Call doc.Save( False, True )
Set dc=doc.Responses
Messagebox dc.count
Call dc.StampAll("SoftDelete","Y")
Set doc = collection.GetNextDocument(doc)
Wend
Messagebox " Reservation has been deleted!"
Call ws.ReloadWindow( )
End Sub
Thanks a lot!
Linda