2
votes

I have an application in lotus domino with a field

UNIDID-number(computed)...

I want that every time a new entry is created, this field to increment by 1 and the new value should be stored in new record document..

I have a @dbcolumn formula which will get me the last entry in the UNIDID field-

mFind:=@DbColumn("" : "NoCache" ; @DbName ; "lkpEmpMasterbyOnlyUnidCode";1);

How do I increment mFind and submit it in form of 'UNIDXXXX'?

4
Is this database replicated to other servers or the system of local users? The distributed nature of Lotus can make this very difficult.Jasper Duizendstra
its for system of local users..Bebo

4 Answers

3
votes

To answer your specific question:

lastEntry := @Subset(mFind;-1); "UNID" + lastEntry;

But here are a couple of things you should think about:

  1. "UNID" is a term that has a very specific meaning in Notes and Domino. It refers to the Universal ID that is automatically assigned to every document in every database. If you use this term in your application for another purpose, you are likely to cause confusion someday when some other Notes expert has to look at your application.

  2. The best way to assign a sequential id is to let the server do it for you. I.e., save the document with an empty field, and create an agent that runs on new and edited documents, checks for the empty field, and assigns the next available id if necessary. Since only one agent can run in the database at a time, and it works on only one document at a time, this guarantees that you can't possibly have two documents that are saved simultaneously with the same unique id. The downside of this is that you can't show the user the sequential id before the agent gets a chance to run.

2
votes

Read the comprehensive treatment of sequential numbering in Notes/Domino written by IBMer Andre Guirard. He considers the use of @DBColumn for sequential numbering a significant performance risk and provides algorithms and code for alternative approaches.

I recommend the approach under the heading "Number Generation On Demand" using the code in Listing 2. Document locking is overkill- merely detecting whether the numbering document has been modified since it was read and reacting accordingly is sufficient.

1
votes

This formula is from my technical notes database, generates a sequentially increasing number using a computed when composed field on the form so user can see the number but it is only fixed when you save the document.

T_List:=@DbColumn("" : "NoCache"; ""; "RefNumView"; 1); @If(@IsNewDoc & @Elements(T_List)=0;1;@IsNewDoc & !@IsError(T_List);@Subset(T_List;1) + 1;RefNumber)

You need a view first column sorted in descending order with the field that stores your number, if the view has no records the code above starts numbering at 1

The database was developed in Notes 4.5 but I'm still using it now with 8.5 notes client & designer and have never needed to change the formula, indeed its been reused many times over the years in all the later versions. It won't work if documents are created on multiple servers, for that the scheduled agent is the only way to get a truly unique sequential numbering.