Create a new document for each value in a field

The script below is used in a form action button for the current document. It will make a new DLE document and populate the Form & dl_category fields with static values. The dl_entry field will get populated with each value from the ListValues field found on the source document.
LotusScript


Sub Click(Source As Button)
	
	Dim workspace As New NotesUIWorkspace
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Set db = session.CurrentDatabase
	Dim uidoc As NotesUIDocument
	Set uidoc = workspace.CurrentDocument
	Dim sdoc As NotesDocument
	Set sdoc = uidoc.Document
	Dim SourceFieldValues As Variant
	SourceFieldValues = sdoc.GetItemValue("ListValues")
	Dim doc As NotesDocument
	
	For J = 0 To Ubound(SourceFieldValues)
		Set doc = db.CreateDocument
		doc.Form = "DLE"
		doc.dl_category="Office"
		doc.dl_entry = SourceFieldValues(J)		
		Call doc.Save(True, True)
	Next J

	MsgBox "Done!"
	
End Sub

Posted by fbrefere001 on Friday March 8, 2002