Auto Numbering


Wonder if anyone could offer some help - I've just designed my first database and now I wish to add autonumber to one of the fields, but I'm unsure of how to do this
Who is Participating?
AndrewJayPollackConnect With a Mentor Commented:
Notes is meant to be used in disconnected, replicated envrionments.  A squential numbering system can be built, but presents serious problems.  If you simply want a unique tag on the field, and it doesn't need to be sequential, make the field computed, and use @Unique() for the formula.  This will produce a multi-digit alphanumeric value that will be unique across all replicas or copies of the database.  

Big picture: Notes database design is more than just thinking through how to do things you do in other tools, you have to learn to think like notes.  This is one example where your application could have scale or rollout problems down the road if you just used a sequential number.
Andrew is right.  The problem with a numbering system is if there are several users operating remotely then they could have 3 separate numbers that could become the same and no way of incrementing one single master number.  We have a system where we have users creating db's on a notes server and also creating documents on a webserver so we increment an ODD number on the notes server and an EVEN number on the webserver to eliminate having duplicate numbers.  We do not allow the db to be copied locally so we don't have the issue of having multiple remote users creating duplicate numbers.

Sno, that works fine as long as it isn't a busy server!  
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Drew what do you mean?  You mean the reading/writing of the profile number somewhere?  It doesn't seem to be a performance issue for us, we just have a profile database with profile numbers and then the profile does a lookup to the appropriate number record, locks the record, increments the record by 2 (because we do the odd-even thing), saves the record, then unlocks the record.

I mean if you allow concurrent web agents (which you generally should) then this can happen concurrently on a busy server.
Hello Kev1609,
Create a computed field, compute after validation, add this formula to the value field in programmer pane.
@If(@IsNewDoc;@Subset(@DbColumn( "" : "NoCache" ; "" : "" ; "(unique#lkup)" ; 1 );1)+1;unique#)
unique# being whatever you want the field called.
unique#lkup is a view created that keeps the numbers.
Create a view sorted decending that contains 1 column that contains the unique#.
This will get you started....
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.