You need to sign in to do that
Don't have an account?
Vishal Saw
Write a trigger that enforces a custom "Account Number" generation logic, ensuring that all newly created Account have a unique account number in the format "ACCT-YYYY-XXXX" where "YYYY" represent the current year and "XXXX"represents sequential no 0001n
Help to create this on apex
Please check with the below code and let me know if any issue arises :
If this helps , please mark this as Best Answer.
Thank you.
If not, then Subrat's solution is pretty good, but will encounter performance issues or just fail if you have too many accounts added in 1 year, as the query could exceed salesforce limits. You could try limiting the return results to the most recently-created account or accounts, but it seems risky.