I made code to generate a sequential number by looking at a view which has the created date, year, and number, and then incrementing the greatest number by one. . . the code is as follows:
Sub Initialize
Dim workspace As New notesuiworkspace
Dim session As New notessession
Dim db As notesdatabase
Dim uidoc As notesuidocument
Dim lookupdoc As notesdocument
Dim doc As notesdocument
Dim view As notesview
Set db = session.currentdatabase
Set uidoc = workspace.currentdocument
Set doc = uidoc.document
xyear = Format(Date , "yyyy")
key = xyear
Set view = db.getview("DocNo")
Set lookupdoc = view.getdocumentbykey(key)
If lookupdoc Is Nothing Then
x = 1
doc.number = 1
Else
y = lookupdoc.number(0)
x = y + 1
doc.number = y + 1
End If
If x <= 9 Then
DocNo = xyear & "-" & "000" & x
Elseif x > 9 And x <= 99 Then
DocNo = xyear & "-" & "00" & x
Elseif x > 99 And x <= 999 Then
DocNo = xyear & "-" & "0" & x
Else
DocNo = xyear & "-" & x
End If
doc.DocNo = DocNo
Call uidoc.Refresh
End Sub
This is the code which I use to generate a sequential number on the “onload” event. It works with its own view which has the year, creation date, and the sequential number of each document created. It looks for the last document, and then increments this number by one. Because of access control issues, I am forced to generate a corresponding hidden document which you helped me with, which will hold these document numbers in an access control free environment. Now, what I am trying to do, is use this agent to look in a view which im calling “DocNoHolder” which stores the corresponding hidden documents of the form “DocNoHolder”, look for that last document, and then output the next sequential number generated on the open document. Can someone show me what i need to change to accomplish this? Thanks