Multiple uidoc's

During the saving of a document that has been filled in by a user, the QS event does some edit checking and based on some criteria, creates a new doc of another form type. Some fields are filed in by the current document being saved. I am trying to get the new document up in front of the user , as there are more fields for them to fill in. I am struggling with this. This is my latest attempt…Sub createopenhousedoc

Dim s As New NotesSession 

Dim ws As New NotesUIWorkspace 

Dim db As NotesDatabase 

Dim uidoc As NotesUIDocument 

Dim doc As NotesDocument

            Dim ohdoc As NotesDocument

Dim location As String

	

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document 

Set ThisDB = s.CurrentDatabase	





UserInput1 = ""

UserInput1 = Inputbox$("Please Enter your Current Job Title", "Current Job Title Input")

	

If doc.location(0) = "blah" Then location = "blah vlah"	ETC ETC



   ' Create the document in this database

Set ohdoc = ThisDB.createdocument

ohdoc.form = "OHD"

ohdoc.client = doc.client(0)

ohdoc.lanid = doc.client_userid(0)

ohdoc.clienttitle = UserInput1			ohdoc.clientlocation = location

ohdoc.clientdept = doc.client_dept(0)

Set ohdoc = uidoc.Document     ' This does not work

Call uidoc.refresh

Call ws.editdocument(True, ohdoc, False,,True,True)                                   ' Therefore this fails.

Call ohdoc.save(True,True)	

End Sub

Subject: multiple uidoc’s

Just remove the offending line, there doesn’t seem any point in it being there, all you’re doing is changing ohdoc to be the current document, which isn’t what you want.

And when you say it doesn’t work, and the editdocument line fails it would be useful if you explained what happened.

Subject: RE: multiple uidoc’s

ya it seems like this is all you should need:

’ Create the document in this database

Set ohdoc = ThisDB.createdocument

ohdoc.form = “OHD”

ohdoc.client = doc.client(0)

ohdoc.lanid = doc.client_userid(0)

ohdoc.clienttitle = UserInput1

ohdoc.clientlocation = location

ohdoc.clientdept = doc.client_dept(0)

Call ws.editdocument(True, ohdoc, False,True,True)

Subject: RE: multiple uidoc’s

Thanks for your quick response.

i changed it to this but now the save gives a 'Database already contains a doc with this ID(unid). Error found attempting quit. Yes to continue editing or No to quit.

Strangely the ohdoc is saved with the fields populated in the script being ok but any populated in the UI are blank;

Set ohdoc = ThisDB.createdocument

ohdoc.form = "OHD"

ohdoc.client = doc.client(0)

ohdoc.lanid = doc.client_userid(0)

ohdoc.clienttitle = UserInput1			ohdoc.clientlocation = location

ohdoc.clientdept = doc.client_dept(0)

Call ws.editdocument(True, ohdoc, False,,True,True)

Call ohdoc.save(True,True)

thanks again.

Subject: RE: multiple uidoc’s

Your problem is the save command at the end of the script.

  • Either you save first and open it on the UI after, in which case you can save in the backend.

  • Or you don’t save at all, and let the user handle the save from the front end.

Otherwise, you have an instance of the document on the front end in the UI document, yet you are saving in the backend, and now you have a save conflict if the user also saves in the front end.