i want to auto increment on when a new record is created using triggers. i have customer object and customer_serial_No field whenever a customer is created customer_Serial_No is incremented
-
3Why not use an autonumber field?– Brian MansfieldDec 13, 2016 at 20:51
-
2I agree that an autonumber field is the tool for the job described here. If that's not an option, you should edit your question to include details on what you've tried so far. As is, this question sounds like a "do it for me" request, which don't tend to garner many answers. I'd recommend reading through the help center on asking questions, specifically how to ask a good question.– Derek FDec 13, 2016 at 21:22
1 Answer
As suggested try to use Auto number field to auto-increment as this can be taken care of by the system. If you still need to have trigger use the customer_serial_no to increment it each time based on the highest value, make sure to create a custom index for this field as it will lead to SOQL error when the data size increases.
Regards, Bharath