Q

Creating an auto-running 'no' for a field

I would like to create an auto-running 'no' for a field and the code as below, but I can't get the result. I can't spot the error.tx.
REM {- This sets up lookup values};
CLASS := "Notes";
CACHE := "Cache";
NOCACHE := "NoCache";
SERVER := "";
DATABASE := "memo.nsf";
VIEW := "(hdocno)";
COLUMN := 1;
REM {- This looks up & returns the 
column of already saved };

LastNum:=
@If(@IsError (@DbColumn(CLASS : 
NOCACHE; DATABASE; VIEW; COLUMN))="";
100000; 
@TextToNumber(@Subset(@DbColumn
(CLASS : NOCACHE; DATABASE; VIEW; 
COLUMN);-1))+1);

@SetField("docno";@Text(LastNum))
This method will only work if you application runs on a single server. Try this variation to the formula.
LastNum:= @DbColumn
(CLASS : NOCACHE; DATABASE; 
VIEW; COLUMN);
NewNum := @If(@IsError(LastNum) ; 
100000; @TextToNumber
(@Subset(LastNum;-1))+1 );
@SetField("docno";@Text(NewNum))
Also, set this so it executes the first time the document is saved, when docno="" & @IsDocBeingSaved, otherwise you may end up skipping and/or get duplicate numbers.

Do you have comments on this Ask the Expert question and response? Let us know.

Dig Deeper on Lotus Notes Domino Formula Language

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close