Currently, this agent assigns a sequential tracking number to a document by looking in a view (DocNo) these documents are stored, finding the greatest number, and incrementing it by one.
Due to security, those documents have access control, so I need to generate a hidden document (DocNo) at the same time which will have the same tracking number but stored in a different view (DocNoHolder) without access control.
I am stumped. Can someone show me how to make this agent look at that access control free view to generate the tracking number while still assigning the tracking number to the original document?? Apparently its not as easy as I thought
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