Follow up- Lotus Notes - Numbering sequence in script reaches limit

captain
captain used Ask the Experts™
on
This is a follow up to this question.

This morning the error recurred, on number 32768 to 32769.

The global code is as suggested:
Function GenSeqNo() As String      
	Dim session As New NotesSession
	Dim w As New NotesUIWorkspace
	Dim db As NotesDatabase
	Dim lookupView As NotesView
	Dim doc As NotesDocument, lookupDoc As NotesDocument
	Dim nextNum As Long     
	
	Set db = session.CurrentDatabase
	
      'This is how you get current document, not using session
	Set doc = w.CurrentDocument.Document
	
	'If doc.IsNewNote Then        'Exit if this is not a new document
	Set lookupView = db.GetView( "SeqNoView" )      'get the view containing the dummy doc
	Set lookupDoc = lookupView.GetFirstDocument( )      'only one doc in view            
	Call lookupDoc.Lock( )
	nextNum = Cint( lookupDoc.SeqNo(0) ) + 1      'retrieve next number            
	lookupDoc.SeqNo = Cstr( nextNum )                  'increment existing number in dummy doc
	Call lookupDoc.Save( True, False, True )
	Call lookupDoc.Unlock( )
	
	GenSeqNo = Cstr( nextNum )
'End If
	
End Function

Open in new window


Whilst the button code remained unchanged:
Function GenSeqNo() As String      
	Dim session As New NotesSession
	Dim w As New NotesUIWorkspace
	Dim db As NotesDatabase
	Dim lookupView As NotesView
	Dim doc As NotesDocument, lookupDoc As NotesDocument
	Dim nextNum As Long     
	
	Set db = session.CurrentDatabase
	
      'This is how you get current document, not using session
	Set doc = w.CurrentDocument.Document
	
	'If doc.IsNewNote Then        'Exit if this is not a new document
	Set lookupView = db.GetView( "SeqNoView" )      'get the view containing the dummy doc
	Set lookupDoc = lookupView.GetFirstDocument( )      'only one doc in view            
	Call lookupDoc.Lock( )
	nextNum = Cint( lookupDoc.SeqNo(0) ) + 1      'retrieve next number            
	lookupDoc.SeqNo = Cstr( nextNum )                  'increment existing number in dummy doc
	Call lookupDoc.Save( True, False, True )
	Call lookupDoc.Unlock( )
	
	GenSeqNo = Cstr( nextNum )
'End If
	
End Function

Open in new window


What also happens is that the note containing the last number (first doc in SeqNoView) stays locked and the error message for this (Note already locked) appears.

Nothing has changed overnight, but it worked from 32767 to 32768 but not anymore.

Baffled! Ideas?

Thanks
capt.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Whoops

Missed this

nextNum = Cint( lookupDoc.SeqNo(0) ) + 1

Cint is converting lookupDoc.SeqNo(0) to an integer as so is breaking the max value

I think it should be

nextNum = Clng( lookupDoc.SeqNo(0) ) + 1

as nextnum is now a long
Sjef BosmanGroupware Consultant

Commented:
Spot on!
captainTechnical Director

Author

Commented:
:)

Thought that was the case but did not know how to translate it...

thx.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

captainTechnical Director

Author

Commented:
Thanks for the quick reply, thanks to you too sjef. (beste dank!)
Thanks for more lovely notes points :-)
Sjef BosmanGroupware Consultant

Commented:
You could have split points again...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial