Document saved via LotusScript requires a resave

I have been searching through the forum but there is just too much stuff that it is hard to find what you are looking for.

I have a mail database and I have created a custom form to display the incoming documents with instead of the standard Memo form. When new emails arrive there is some data I would like to prefill before the document is delivered to the user. I am creating a agent that currently runs from the menu and will eventually run on a schedule to prefill data in the email. I am finding that everything is filled in and the document does save but the documents will not display in any views until I edit and save the document. I can open the document and see that is is displaying with my custom form and that the data I wanted prefilled was visible. The views have a basic selection criteria where it selects documents based upon the alias of the form. I have attached my code which is quite common so I was wondering if anyone knows why this is happening. Thanks.

Sub Initialize

Dim db As NotesDatabase

Dim session As New NotesSession

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim j As Integer

searchFormula$ = { @Contains(Form; “Memo”:“frmVrsRequest” ) }

Set db = session.CurrentDatabase

Set collection = db.Search( searchFormula$, Nothing , 0 )

For j = 1 To collection.Count

Set doc = collection.GetNthDocument ( j )

doc.Form = “frmVRSRequest”

doc.Converted = “Yes”

doc.ReplaceItemValue “DateCreated”,doc.Created

doc.ReplaceItemValue “Associates”, “”

doc.ReplaceItemValue “EmployerName”, “”

If Instr(doc.Subject(0), “Billing”) Then

doc.ReplaceItemValue “RequestType”, “Billing”

Elseif Instr(doc.Subject(0), “Claims”) Then

doc.ReplaceItemValue “RequestType”, “Claims”

Elseif Instr(doc.Subject(0), “Conversions”) Then

doc.ReplaceItemValue “RequestType”, “Conversions”

Elseif Instr(doc.Subject(0), “CustServ”) Then

doc.ReplaceItemValue “RequestType”, “Customer Service”

Elseif Instr(doc.Subject(0), “TechAssistance”) Then

doc.ReplaceItemValue “RequestType”, “Technical Assistance”

Elseif Instr(doc.Subject(0), “Underwriting”) Then

doc.ReplaceItemValue “RequestType”, “Underwriting”

Elseif Instr(doc.Subject(0), “UserID”) Then

doc.ReplaceItemValue “RequestType”, “User ID Maintenance”

Else

doc.ReplaceItemValue “RequestType”, “Other”

End If

doc.ReplaceItemValue “Priority”, “Medium”

doc.ReplaceItemValue “HOIntervention”, “No”

doc.ReplaceItemValue “ActionTaken”, “”

If doc.Save(True, False) = False Then

Print “Document was not saved”

End If

Next

End Sub

Subject: Document saved via LotusScript requires a resave

Hi,

To enable viewing doc’s in a view or folder, the fields should be flaged as SUMMARY.

To achieve this you have to save the document with the form.

There is a function to do this, but I can’t recall it right now.

HTH

Daniel

Subject: RE: Document saved via LotusScript requires a resave

Since I did not explicitly create a new note item for each field I call ReplaceItemValue for do you think this has anything to do with it?

Should I add statements like:

Dim item As NotesItem And Set item = New NotesItem _

( doc, “Topic”, “I have something to say” )

item.IsSummary = True

I went back and ran my agent against one new document and in the document properties the fields that I created on the fly which are not on the memo form but are on my custom form the Field Flag was set to Summary for each one.