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

Auto number field to update separately for each Region

HI i am trying to write an trigger in case ,if region is chennai i have an autonumber field it should be ch-000

for pune pun-000,i want the each region to autonumber separately.

Manu ErwinManu Erwin

Hi anitha20,

unfortunately auto-number fields do not work like that as they increment based on the format defined on the field. It's effectively a formula field for your purposes, i.e., you can read it but cannot update.


Is this for reporting purposes or user (i.e., user who deals with cases) requirement?


If it's for reporting I suggest making use of totals etc to get the numbers that management are likely wanting.


If it's at the user level then I'd be interested in hearing the User Story (i.e., requirement/use case).


If the users are adamant they need to see Pune-001, Pune-002, Pune-00n and same for Chennai then there are ways to solve this however considering the potential number of Case records you may have over time you should be careful of Governor Limits ( - I'm aware these are being relaxed/improved with Spring 11 however you still need to be careful.



We are having an custom application object having a auto number field which is mandatory; can you please help how can I write a apex code to insert value in the custom object; the problem is that as autonumber field is mandatory system is throwing exception during insert operation without assigning some value to autonumber field and if we try to assign some value then system throws exception that we can not assign values to autonumber fields