Script question

Hi,I have a view with some documents and would like to create a new document in the backend for each document in the view, including some information from the original doc. I try this script, but it only saves the last document and not all.

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim parent As NotesDocument

Set db = session.CurrentDatabase

Set view = db.GetView("CFP")

view.AutoUpdate = False

Set parent = view.GetFirstDocument

Set doc = db.CreateDocument



While Not (parent Is Nothing)

	doc.AWB = parent.GetItemValue("AWB")

	doc.Form = "Deckblatt"	

	Call doc.ComputeWithForm( True, True )	

	Call doc.Save(True, False)

	Set parent = view.GetNextDocument(parent)

Wend

End Sub

It looks like something with saving each doc doesn’t work, but I have no idea where my error is. Thanks.

Oliver

Subject: Script question

Oliver,

You need to put “set doc=db.CreateDocument” AFTER the While Not statement.

You are only creating one document and then saving it many times!!

HTH

Mike

Subject: Script question

Great,thanks for the quick answer.

It works.

Subject: Script question

Hi Oliver,

You need to move the line

“Set doc = db.CreateDocument”

inside the while loop so that a new doc is created for each parent.

hth

Richard