Subject: RE: …but that second document might get the CMUnique changed if the document is reseved from the GUI
Hi Graham, Yes, I am trying to fix a problem that is the ReferralID doesn’t match that of the active initial referral, which causes the menu to display the wrong set of documents for creation.
if possible can I ask the details to fix the problem? how to re-worked to keep the same UNID for creating (inherit/edit) document later on? the coding is below.
Thanks a lot.
linda
Sub Click(Source As Button)
On Error Resume Next
Dim session As New NotesSession, db As NotesDatabase, doc As NotesDocument
Dim ws As New NotesUIWorkspace, uidoc As NotesUIDocument
Dim ndbAdmin As NotesDatabase, ndbSummary As NotesDatabase
Dim nvSummary As NotesView, nvAdmin As NotesView
Dim ndSummary As NotesDocument, ndAdmin As NotesDocument, ndDelete As NotesDocument, ndTemp As NotesDocument
Dim userdb As NotesDatabase, userview As NotesView, userdoc As NotesDocument
Dim newdoc As NotesDocument
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then Msgbox "Select a Case Record first." : Exit Sub
If dc.Count > 1 Then Msgbox "Only Select 1 Case Record." : Exit Sub
Set doc = dc.GetFirstDocument
theserver = db.Server
thepath = doc.thepath(0)
Set userdb = session.GetDatabase(theserver, thepath)
If userdb.Title="" Then
'get summary, doc
Set ndbSummary = session.GetDatabase(theserver, "IFRs\MCSSSummary.nsf")
Set nvSummary = ndbSummary.GetView("(sumbyub)")
Set ndSummary = nvSummary.GetDocumentByKey(doc.UniqueBind(0))
If ndSummary Is Nothing Then
Msgbox "Case cannot be located. Please contact the Help Desk. Error 139"
Else
Set userdb = session.GetDatabase(theserver, ndSummary.thepath(0))
If userdb.Title="" Then
Msgbox "User database cannot be located. Please contact the Help Desk. Error 149"
Else
Set userview = userdb.GetView("(vwAllCM)")
Set userdoc = userview.GetDocumentByKey(doc.UniqueBind(0))
If userdoc Is Nothing Then
Msgbox "Case cannot be located. Please contact the Help Desk. Error 169"
Else
Set newdoc = userdb.CreateDocument
Call userdoc.CopyAllItems(newdoc)
newdoc.Form="(frmCMView)"
newdoc.CMUnique=userdoc.UniversalID
newdoc.SummaryHide="1"
Call newdoc.Save(False, False)
Call ws.EditDocument(False, newdoc)
’ Call ws.EditDocument(False, userdoc)
End If
End If
End If
Else
If Not userdb.Title="" Then
Set userview = userdb.GetView("(vwAllCM)")
Set userdoc = userview.GetDocumentByKey(doc.UniqueBind(0))
If userdoc Is Nothing Then
Set ndbSummary = session.GetDatabase(theserver, "IFRs\MCSSSummary.nsf")
Set nvSummary = ndbSummary.GetView("(sumbyub)")
Set ndSummary = nvSummary.GetDocumentByKey(doc.UniqueBind(0))
If ndSummary Is Nothing Then
Msgbox "Case cannot be located. Please contact the Help Desk. Error 169"
Else
Set userdb = session.GetDatabase(theserver, ndSummary.thepath(0))
If userdb.Title="" Then
Msgbox "User database cannot be located. Please contact the Help Desk. Error 179"
Else
Set userview = userdb.GetView("(vwAllCM)")
Set userdoc = userview.GetDocumentByKey(doc.UniqueBind(0))
If userdoc Is Nothing Then
Msgbox "User database cannot be located. Please contact the Help Desk. Error 199"
Else
Set newdoc = userdb.CreateDocument
Call userdoc.CopyAllItems(newdoc)
newdoc.Form="(frmCMView)"
newdoc.CMUnique=userdoc.UniversalID
newdoc.SummaryHide="1"
Call newdoc.Save(False, False)
Call ws.EditDocument(False, newdoc)
'Call ws.EditDocument(False, userdoc)
End If
End If
End If
Else
Set newdoc = userdb.CreateDocument
Call userdoc.CopyAllItems(newdoc)
newdoc.Form="(frmCMView)"
newdoc.CMUnique=userdoc.UniversalID
newdoc.SummaryHide="1"
Call newdoc.Save(False, False)
Call ws.EditDocument(False, newdoc)
'Call ws.EditDocument(False, userdoc)
End If
End If
End If
End Sub