Link to home
Start Free TrialLog in
Avatar of captain
captainFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Lotus Notes - Numbering sequence in script reaches limit

Hi

this is a code we have been using in a Notes Document to generate a number for use in a document, based on a +1 increment from the previous number used.

The code was discussed in this Question

It has been working great until now that we have reached sequential number 32767, which according to IBM is the maximum value limit to integers being used in additions.

According to the above KB, the workaround is to use a '1.0' instead of a '1' to add, but this does not work in the code below.


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 Integer      
	
	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.0      '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


MQ: Is it possible to amend the code to use the workaround? If so how?

Thx
capt.
SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of captain

ASKER

Perfect idea, let me try.
Avatar of captain

ASKER

Thanks both that did the trick!
Thanks for first Notes points :-P
Danke Herr Kapitän!

@Andy, happy to have shared some with you! :)
Avatar of captain

ASKER

Hi Guys

This has stopped working today, I am getting lock errors and overflow errors, not sure why and how.

New Q opened, see here

Thx
capt.