OpenNTF.org - Assign Next Consecutive Number
    Advanced
   OpenNTF Code Bin
Edit Document Code By Rating > Code Document
About This Code
Brief Description:
Assign Next Consecutive Number (Uses Environment Variable) 
Rating:
Rating: 5 , Number of votes: 1 
Contributor:
Andrew Jones 
Category:
Lotus Formula 
Type:
 
Last Modified:
17 Jun 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
In the default value of a field, use this formula to assign the next consecutive number using an environment variable: REM "Retrieve last number from the Environment variable"; Temp := @Environment("Num"); REM "Start with zero if the Environment variable came back blank"; Temp2 := @If(Temp = ""; "00000"; Temp); REM "Change to numeric"; CurrentNum := @TextToNumber(Temp2); REM "Add one to get the next number"; NextNum := CurrentNum + 1; REM "Calculate number of zeroes you need to pad with to get a five-digit number"; Zeroes := (NextNum < 10000) + (NextNum < 1000) + (NextNum < 100) + (NextNum < 10); REM "Assign and save the number - converting it back to text"; ENVIRONMENT Num := @Repeat("0"; Zeroes) + @Text(NextNum); REM "Return the new number as a text string"; Num
Usage / Example
 Comments
Posted by Rafidah Hanum Abdul Rashid on 06/03/2005 01:32:24 AMAuto Numbering
Set the field as computed when compose...It's really works!
 Add your comment!