Lotus Notes/Lotus Designer

Lotus Script 로 Collection 이용하기

지병철 2013. 11. 21. 14:00
Sub Initialize

 On Error GoTo errHandle

 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim collection As NotesDocumentCollection
 Dim doc As NotesDocument

 Dim num$, FunctionNumber$, approver$, apprdate$, requester$, subject$

 Set db = session.CurrentDatabase
 Set collection = db.UnprocessedDocuments
 Set doc = collection.GetFirstDocument()

 While Not(doc Is Nothing)
 	num$ = CStr(getLastNum)
 	num$ = UString(4-Len(num$), "0") + num$
 	functionNumber$ = doc.Getitemvalue("FunctionNumber")(0)
 	approver$ = doc.Getitemvalue("Approver6")(0)
 	apprdate$ = doc.Getitemvalue("ApprDate" + functionNumber$)(0)
 	subject$ = doc.GetItemValue("Subject")(0)
 	requester$ = doc.GetItemValue("RequesterName")(0)

 	if MakeDocument(requester$, approver$, apprdate$, subject$, num$)= False Then
		MsgBox "코드양식 작성 중 문제가 발생했습니다!" + " = " + Functionnumber$ + ", " + approver$ + ", " + apprdate$ + ", " + subject$ + ", " + requester$
		GoTo closing
	End If

	doc.indexNumber = num$
	doc.RequestID = "반품20" + num$

 	Call doc.save(False, True)

	Set doc = collection.GetNextDocument(doc)
Wend

closing:
	Exit sub

errHandle:
	MsgBox "에러가 발생했습니다!"
	Resume closing 
End Sub