I have 1 DB need to create auto Unique ID each document after Approver approve the document.
Currently the unique ID will generate before Approver approve the document. Even the document save as a draft the unique number will Auto generate.
Below is my code:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim doc As notesdocument
Dim curdoc As notesdocument
Dim result As Variant
Dim strRunNo1 As String
Dim strRunNo As String
Dim Max As String
Dim Min As String
Set db=session.currentdatabase
Set view = db.GetView("InvNoLookup")
Set doc = view.GetFirstDocument
If Source.IsNewDoc Then
'If doc Is Nothing Or TmpInvNo= MaxInvNo Then
If doc Is Nothing Then
'Call source.FieldSetText ( "TmpInvNo", Cstr(MinInvNo))
Call source.FieldSetText ( "TmpInvNo", "310857")
Else
If doc.TmpInvNo(0) =399999 Then
Call source.FieldSetText ( "TmpInvNo", "300000")
Else
strRunNo1 =Trim(doc.TmpInvNo(0))
strRunNo = Trim(strRunNo1+ 1)
Call source.FieldSetText ( "TmpInvNo", strRunNo)
End If
End If
End If
Call Source.Refresh
'If Source.IsNewDoc Then
'If doc Is Nothing Or iudoc.TmpInvNo=doc.MaxInvNo Then
'If doc Is Nothing Then
' Call source.FieldSetText ( "TmpInvNo", MinInvNo)
'Else
' If doc.TmpInvNo(0) = doc.MaxInvNo(0) Then
' Call source.FieldSetText ( "TmpInvNo", MinInvNo)
' End If
' strRunNo1 =Trim(doc.TmpInvNo(0))
' strRunNo = Trim(strRunNo1+ 1)
' Call source.FieldSetText ( "TmpInvNo", strRunNo)
'End If
'End If
End Sub
TextField Name : Status
Status list : 1)Pending on Approval 2) Approve