I have the following agent which works beautifully after the first sequential number has been assigned. Now that the database has been moved to production its not prompting if there is no previous sequential number.
Can anyone tell me why my code is failing? Thanks!
Sub Initialize
Dim s As New notesSession
Dim ws As New notesuiworkspace
Dim db As notesDatabase
Dim profileDoc As notesDocument
Dim uidoc As notesuiDocument
Dim thisDoc As NotesDocument
Dim seqNumber As Long
Dim seq As Long
Dim inputStr As String
Dim qtNumber As String
Dim un As String
Dim unInitials As String
’
'First, check to see if the Seq number document already exists.
Set db= s.currentDatabase
Set uidoc=ws.currentDocument
Set thisDoc=uiDoc.Document
Set profileDoc = db.Getprofiledocument("SeqNumberDoc")
If (Cstr(profileDoc.SeqNumber(0))="") Then
'if Not, prompt for the number
inputStr=Inputbox ( "Please specify a number:" , "Enter Number" )
Else
'if so, prompt for a new number, with the existing number as a default
inputStr = Cstr(profileDoc.SeqNumber(0))
End If
unInitials=thisDoc.Initials(0)
qtNumber=thisDoc.IssueNum(0)
seqNumber=Clng(profileDoc.SeqNumber(0))
thisDoc.IssueNum=unInitials & Cstr(seqNumber)
profileDoc.SeqNumber=seqNumber + 1
'Verify that the input was numberic
On Error Goto aa
seq =Clng(inputStr)
aa:
If seq=0 Then
mb=Msgbox("The value that you entered was not numeric or was zero. Please try again.",16,"Error")
Exit Sub
End If
Set thisDoc = uidoc.document
unInitials = thisDoc.Initials(0)
qtNumber=thisDoc.IssueNum(0)
Call profiledoc.save(1,0)
If thisDoc.saveOptions(0) = "0" Then Exit Sub
If qtNumber<> "<<Draft>>" Then Exit Sub
Set profileDoc = db.Getprofiledocument("SeqNumberDoc")
seqNumber= Clng(profileDoc.SeqNumber(0))
thisDoc.IssueNum= unInitials &Cstr(seqNumber)
profileDoc.SeqNumber = seqNumber + 1
Call thisDoc.save(1,1)
'Notify the user that the number has been successfully changed.
'mb=Msgbox("The sequential application number has been set to " &inputStr,64,"Number Set")
End Sub