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.Sale_Num= Trim(Str$(Val(docA.Sale_Num(0))+1))
docB.Author = session.CommonUserName
Call docB.RemoveItem( "SaveOptions" )
docB.Signature = ""
docB.PrintedSig = ""
docB.Quote_Date = Evaluate ("@Now")
docB.S = ""
Call docB.Save( True, True )
End If
'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.Sale_Num= Trim(Str$(Val(SNdoc.Sale_Num(0))+1))
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)
Wend
End If
Software/Hardware used:
ASKED:
November 18, 2005 12:18 PM
UPDATED:
November 18, 2005 12:38 PM