Create response doc then make it UIDoc

I need to programmtically create a new uidoc that is a response to another document that I have selected via LotusScript (see formula below). I can’t figure out how to create this document and then set it as a response to the programmatically selected document. Because MakeResponse is a method of the Document class, I’m not sure how to create the document and then bring it into the UIWorkspace as the UIDocument. HELP!

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim currentdb As NotesDatabase

Dim db As Notesdatabase

Dim user As String

Dim fuser As String

Dim luser As String

Dim keyname As String

Dim personview As NotesView

Dim pdoc As NotesDocument  

Dim reqdoc As NotesDocument

Dim uidoc As NotesUIDocument

	

Set currentdb = session.CurrentDatabase

sname = currentdb.Server

Set db = session.GetDatabase(sname, "gsoft\gshd.nsf")



'get profile document by key of lastname,firstname of user

'create key

user = session.CommonUserName

fuser = Strleftback(user, " ")

luser = Strrightback(user, " ")

keyname = luser + ", " + fuser



'get document

Set personview = db.GetView("(peopleonly)")

Set pdoc = personview.GetDocumentByKey(keyname)	



'create response doc of help request



**this is where I'm stuck...I need to create the response doc based on pdoc (they are in the same database) and then bring it to the UIWorkspace as the UIDocument

Subject: Create response doc then make it UIDoc

simply create the response doc, save it. and open it with notesuiworkspace.editdocument.

Subject: Create response doc then make it UIDoc

Dim pdoc As NotesDocumentDim reqdoc As NotesDocument

Dim uidoc As NotesUIDocument

Set pdoc = personview.GetDocumentByKey(keyname)

'create response doc of help request

Set reqDoc = db.createdocument

‘’’ add all your reqDoc field values here

reqDoc.Form = “Response”

'etc.

Call reqDoc.MakeResponse(pdoc)

Set uidoc = workspace.EditDocument( True, reqDoc )

Subject: RE: Create response doc then make it UIDoc

Thanks Ester…I can see how that works, EXCEPT that when I do this, the code creates the pdoc on my workspace, not the reqdoc (the forms are different).

I’m wondering what you mean by "'add all your reqDoc field values here – do I have to delcare all the values that inherit from the original form?

Subject: RE: Create response doc then make it UIDoc

I’m wondering what you mean by "'add all your reqDoc field values here – do I have to delcare all the values that inherit from the original form?

Absolutely. While doc.computewithform will fire all your default value formulas as well as some (although not necessarily all, which is why it’s documented that it won’t fire any) of your computed field formulas, it won’t do your inheritance. Inheritance only works when a document is created from the UI.

(btw, I apologize for my previous post which said less than Esther’s. It wasn’t an attempt to contradict her posting, which was made earlier than mine; instead a combination of replication delay and webquerysave agent delay sometimes results in one poster not seeing another poster’s earlier post until after making their redundant post.)

Subject: RE: Create response doc then make it UIDoc

Well, then change the code so that reqDoc.Form contains the correct form. You said it was a response, so I assumed it was the standard Response form.