function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David OvellaDavid Ovella 

How to create a validation rule that only allow a custom number field go in consecutive numbers?

Hello, I want to know if it's possible to create a validation rule to let a number field be created only in a consecutive order
Example: (001 to 100)
PreImpreso 001
PreImpreso 002
If I try to enter 004 and 003 it was not entered yet, I get the error "number isn't going in consecutive order"
 
AshlekhAshlekh
Hi,

This task can't be completed by validation rule. Because validation rule fire on current record and don't know the last record value.

You need to write a trigger for this to validate the data.

-Thanks
Ashlekh Gera
David OvellaDavid Ovella
thanks for answer Ashlekh Gera, by any chance do you have any example of triggers where I could see how to do it?


 
Mitali DhingraMitali Dhingra
You can simply use Auto number ...