I have two problems with the following:I have a main “Project” form and a “Summary” form that’s a Response and inherits 2 fields from the “Project” form. In a view, the user selects a particular Project and clicks the action button which creates the Summary (Response) doc.
FIRST PROBLEM:
I am doing this in Script so as to catch if the user selects more than one document. This is working, however, after the Response doc comes up, the focus immediately jumps back to the view. I have gotten around this by using @Command([Compose]) but I would like to use script.
SECOND PROBLEM:
A Project can only have 1 Summary doc. So, in the QuerySave of the Response form, I would like to search for the ‘Parent’ doc and set a flag so another user can’t create another Summary doc for the Project. My code is:
Set ParentView = Db.GetView( “LUDocID” )
SearchID = Cstr(doc.~$Ref(0))
Set ParentDoc = ParentView.GetDocumentByKey( SearchID )
If (ParentDoc Is Nothing) Then
Msgbox"The parent document for this Summary Doc could not be found.", 64, “No Parent Doc”
Else
ParentDoc.SummFlag = “Yes”
Call ParentDoc.Save( False, False )
End If
In the debugger, SearchID is not being populated.
Any help with these is appreciated! Thanks
Subject: locate parent document (was Set field on Parent document)
Hi
To locate the parent document , why not used the ‘ParentDocumentUNID’ property of the NotesDocument class.
e.g.
Set parentDoc = db.GetDocumentBYUnid( doc.ParentDocumentUNID)
This means no need for a lookup view or a searchID string.
HTH
andyG
Subject: Set field on Parent document
Hi again
for your first problem, you could try the following code
Sub Click(Source As Button)
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As Notesdatabase
Dim uiview As NotesUIView
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set uiview = ws.CurrentView
Set dc = uiview.Documents
Set doc = db.GetDocumentByID(uiview.CaretNoteID)
If dc.count = 0 Then
Messagebox "No documents selected",, "Error"
Exit Sub
End If
If dc.Count > 1 Then
Messagebox "More than 1 document selected",, "Error"
Exit Sub
End If
'i have found that u can highlight one document in view, and select another document and run this script
'what will happen is that you will inherit the values for the highlighted document, not the selected document
'so do a test to see if the highlighted document is the same as the selected document.
If doc.NoteID = dc.GetFirstDocument.NoteID Then
Set uidoc = ws.ComposeDocument ( "", "", "Response" )
Else
Messagebox "Confusion in document selection",, "Error"
Exit Sub
End If
End Sub
HTH
andyG