Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger AutonumberRecTypeCustomer on Account (before insert, before update) { list<Account> Acc= [SELECT Id,Name,Customer_Number__c FROM Account WHERE Customer_Number__c !=:null order by Customer_Number__c desc limit 1]; decimal maxlead = Acc[0].Customer_Number__c; for(Account Acci:Trigger.new){ if(Acci.RecordTypeId =='012a3456789BCde'){ Acci.Customer_Number__c = Integer.valueOf(maxlead)+1; maxlead++; } } }
Autonumber for a field based on record type is only way is you can able to do it based on the apex trigger ( before insert )
like below