Hi,
I have a problem with a field which is an autonumber (computed when composed). This value is from a hidden view.
when two users are composing a document, the field stores the same value because it takes from the last number from the hidden view.
How can I prevent to duplicate this autonumber?
Subject: Prevent to duplicate autonumber
you have to add some code to check the value when saved. do a lookup to the view that stores the numbers. One user will win, whoever saved the document first, and the other will lose and your code should advance the number.
Subject: RE: Prevent to duplicate autonumber
The problem is that field is a computed when composed and the value is taken when create a new doc. Autonumber takes the last number + 1.In fact, I’ve no clue to do this.
Subject: RE: Prevent to duplicate autonumber
You can’t do sequential numbering using a view and a computed-when-composed field without duplicates. Period. Use a computed field and assign the number on save, or give up on the idea of sequential numbering (which is a much better idea in Notes in any case – use @Unique to generate a UNIQUE identifier instead).
Subject: RE: Prevent to duplicate autonumber
If I use a computed field each time the doc is edited the value changes beacuse it’s calculated again, and this field must be the same always.
Subject: RE: Prevent to duplicate autonumber
No, you can write a formula that only computes when the docment is being saved for the first time ever using @IsNewDoc and @IsDocBeingSaved.
Subject: RE: Prevent to duplicate autonumber
mmm…the computed when composed field formula is:
LN :=@DbColumn(“”:“NoCache”; “”; “(autonumber)”; 1);
LastNumber := @If(@IsError(LN) | LN=“”; “00000”; @Subset(LN; 1));
@Right(“00000” + @Text(@TextToNumber(LastNumber) + 1); 5)
I cannot restrict using @isdocbeingsaved because the doc is edited many many times.
Subject: RE: Prevent to duplicate autonumber
Did you just decide to ignore the @IsNewDoc part of my posting?
Subject: RE: Prevent to duplicate autonumber
OK, 