Well following is the requirement.
There is a proposal which could be of one or multiple pages .In the case of multiple pages those documents are the response documents. In future if there a similar kind of proposal to be sent then the user clicks another button so that a copy of the same can be created .The code that I have currently creates only the first document and not those response document i.e those extra pages .Hence I created a view where I am capturing only the responses and in the first categorized column in the view I am looking at the $ REF field , so that I first get the Parentdocumentuind and for all instances of those $ Ref create as many as documents .Now the problem is again the code is not creating the new parent document and its creating only the reponse documents .
Following is the code .
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim view As NotesView
Dim SNview As Notesview
Dim collection As NotesDocumentCollection
Dim docA As NotesDocument
Dim docB As NotesDocument
Dim docC As NotesDocument
Dim docD As NotesDocument
Dim SNdoc As NotesDocument
Dim count As Integer
Dim item As NotesItem
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set docA = uidoc.Document
Set view = db.GetView("(OLUResp)")
Set SNview = db.getview("(OLU1)")
Set collection = view.GetAllDocumentsByKey(Cstr(docA.UniversalID))
'Set collection = view.GetAllDocumentsByKey (Cstr(docA.ParentDocumentUnid))
'create new parent
If Not (docA Is Nothing) Then
Set docB = New NotesDocument( db )
Call docA.CopyAllItems( docB, True )
docB.Author = session.CommonUserName
Call docB.RemoveItem( "SaveOptions" )
docB.Signature = ""
docB.PrintedSig = ""
docB.Quote_Date = Evaluate ("@Now")
docB.S = ""
Call docB.Save( True, True )
'create new response docs
count = collection.Count
If collection.Count > 0 Then
Set docD = collection.GetFirstDocument()
Set SNdoc = SNview.getfirstdocument
While count > 0
Set docC = New NotesDocument( db )
Call docD.CopyAllItems( docC, True )
'docC.$REF = docB.ParentDocumentUnid
Set item = docC.ReplaceItemValue( "$REF", docB.UniversalID )
docC.Author = session.CommonUserName
Call docC.RemoveItem( "SaveOptions" )
docC.Signature = ""
docC.PrintedSig = ""
docC.Quote_Date = Evaluate ("@Now")
docC.S = ""
Call docC.Save( True, True )
count = count - 1
Set docD = collection.GetNextDocument(docD)
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!