Document number generation

I have been tasked to change the formula for generating Doc. # on a web app. I am more of an admin than a developer and wanted any help on what I can change on the code below so that instead of generating doc #'s using the users initial and randon numbers, the code should generate the doc #'s as follows:

DATE+DAILY SEQUENCE

The DATE should be YYYYMMDD

The daily SEQUENCE should always begin as 01

This way the first doc for the day should be e.g. 2006101201 and then the next one 2006101202.

Any help here is so much appreciated.

The current code is:

v_firstname:= @If(@IsNotMember(“” : “Anonymous”;@Name([CN];@UserName));

    @Left(@Name([CN];@UserName);" ");

    ""

);

v_lastname:= @If(@IsNotMember(“” : “Anonymous”;@Name([CN];@UserName));

    @RightBack(@Name([CN];@UserName);" ");

    ""

);

v_user:= @Left(@Trim(v_firstname); 1) + @Left(@Trim(v_lastname); 1);

@If(@Trim(v_user) = “”;

    "XX" + @RightBack(@Text(@Unique); 6) + @Text(@Integer(@Random * 10));

    v_user + @RightBack(@Text(@Unique); 6) + @Text(@Integer(@Random * 10))

)

Subject: Document number generation

Doing sequential numbering in Lotus notes is pretty difficult due to the disconnected nature of Notes.

In order to know the next number in a sequence, the formula needs to know the CURRENT number. However, right at that moment a document could have been generated on someone’s machine locally. Once they replicate - bang, you have a new document that you haddn’t considered and duplicated numbers.

If EVERYTHING is going to happen on the server (say a web-only application) then you might have a seqNumber field on the form. When composing that document you would do a lookup to a view of documents sorted decending on that field. Just insert one more than the first document and SAVE. (Your final number field just concatenates this field value on the Date.)

Note that this method is still dangerous, because two documents could be composed more or less simultaniously and STILL get duplicate numbers.

If unique numbers are critical I would stay away from trying it at all.

Subject: RE: Document number generation

Thanks Brian, you’ve shed so much light to me. I did not think of that. I think I will leave things as is for now.

Once again, thanks for you prompt and informative response.

Sanjay

Subject: RE: Document number generation

You bet.

I think the shortest random number you can make is like this:

@If(@IsNewDoc; “EX.” + @Unique; Number)

…which would make a number like…

EV.DINM-6UHKGF