+ Start a Discussion
David OvellaDavid Ovella 

How to create a trigger that allow a custom number field go in only consecutive order?

Hello, I want to know if it's possible to create a trigger 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 was not entered yet, I get the error "number isn't going in consecutive order"
James WooleyJames Wooley
This sounds like a business case for an Auto-Number field, rather than a trigger to me!

See https://help.salesforce.com/apex/HTViewHelpDoc?id=custom_field_attributes.htm&language=en#Auto-NumberFormattingExamples (https://help.salesforce.com/apex/HTViewHelpDoc?id=custom_field_attributes.htm&language=en#Auto-NumberFormattingExamples) for some examples.