Create data list document for each value of a field in the selected document in a view.

The script below is used in a view action button for the selected document. It will make a new data list 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.
Lotus Notes View • LotusScript

Sub Click(Source As Button)
	Dim session As New NotesSession
	Dim workspace As New NotesUIWorkspace
	Dim db As NotesDatabase
	Set db = session.CurrentDatabase
	Dim collect As NotesDocumentCollection
	Set collect = db.UnprocessedDocuments
	If collect.count = 0 Then
		Msgbox " No Document selected!", 0 + 16
		Exit Sub
	End If
	If collect.count = 1 Then
		Dim sdoc As NotesDocument
		Set sdoc = collect.GetFirstDocument
		If sdoc.Form(0) = "Lookup List" Then
			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_entry = SourceFieldValues(J)		
				Call doc.Save(True, True)
			Next J
			Msgbox "Done!"
			Msgbox "You did not select a valid Lookup List document, please try again.", 0 + 16
		End If
		Msgbox "You have selected more than one document, please correct and try again.", 0 + 16
	End If
	Call workspace.viewrefresh

End Sub

Posted by fbrefere001 on Tuesday March 12, 2002