HELP! UIDOC retaining backend document

This code worked beautifully in 5.10. We have upgraded to 6.5.3 and now the UIDOC is displaying the backend document and not the new document for editing. I’ve tried everything, to no avail, and can’t figure out why this is happening. What I’m doing is a collection of documents from a view selection, grabbing one field value for creating a temp variable, then passing it to a new form, an email memo, and placing that value as well as other values from the original doc into the email memo. Before, this worked just fine. Now it’s giving me a blank version of the original form instead of the email memo for viewing and editing. Hopefully, someone knows how I can get this to work again. Here is the code:

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument	

Set db = session.CurrentDatabase

'Collect all the documents selected by the user

Set collection = db.UnprocessedDocuments



Dim SetDate As String

Dim TwoWkeMailDte As String

Dim BccTo As String

Dim BccList As String

BccList = ""



i = 0

For i = 1 To collection.Count 

	Set doc = collection.GetNthDocument( i )

	doc.EditMode = True

	BccTo = doc.EMail(0)

	BccList = BccList  & BccTo & ","

	SetDate = Today()

	doc.TwoWkEmailDte = SetDate

	Call doc.Save( False, True )

Next



Dim workspace As New NotesUIWorkspace

Dim doc1 As NotesDocument

Dim item As NotesRichTextItem

Set uidoc = workspace.CurrentDocument

Set doc1 = New NotesDocument(db)



doc1.Form = "Memo"

doc1.BlindCopyTo = BccList

doc1.Subject = "Reminder of Upcoming Training, Course Name: " + doc.Course(0)  

Set item = New NotesRichTextItem( doc1, "Body" )

Dim longtext As String

longtext = "This is a reminder that you are scheduled to attend the training course " & Trim$(doc.Course(0)) + " on " & Trim$(doc.CIDate(0)) + _ 

" being held at "  & Trim$(doc.TrngFacAdd(0)) +" from " & Trim$(doc.CIHours(0)) +".  If you are unable to attend, please notify this office."

Call item.AppendText( longtext)

Call doc1.Save (False, False)

Set uidoc = workspace.EditDocument(False, doc1)

End Sub

Subject: HELP! UIDOC retaining backend document

Beverly

You set uidoc = workspace.currentdocument earlier in the code. Just remove this and it should be fine

A couple of other things though:

When looping through a document collection, use a Do Until construction (or Do While).

Using getnthdocument is not efficient, and while in small loops it probably doesn’t make much difference, the larger the loop becomes the slower your code will become.

Also, does doc really have a field called EditMode? There’s no property of a notesdocument called EditMode, so all you’re doing is creating an item on the form called EditMode if it’s not there already. I imagine you’re getting confused with the uidoc.editmode property.

hth

Dan

Subject: RE: HELP! UIDOC retaining backend document

Thanks Dan.

I removed the earlier setting of the uidoc. It’s still giving me the blank original form not the email memo. This is so strange. Thanks also for the tips. Once I get this working properly, if ever, I’ll change the code and use a Do Until construction and I also commented out the EditMode reference. Geez, I wish I knew why this isn’t working…