You need to sign in to do that
Don't have an account?
Nagesh Nagarajarao
Trigger / Apex to generate a code (autonumber) in the text field
Hi,
I am looking at generating a 12 digit code code as autonumber for a text field.
Output : JOHN-2201-0025
{!LEFT( <object>.OwnerId , 4)} + '-' +day(today())+month(today())+ '-' + <autonumber>}
a. Let me know whether this is possible using triggers (before insert, before update>?
I am looking at generating a 12 digit code code as autonumber for a text field.
Output : JOHN-2201-0025
{!LEFT( <object>.OwnerId , 4)} + '-' +day(today())+month(today())+ '-' + <autonumber>}
a. Let me know whether this is possible using triggers (before insert, before update>?
Helper Class
All Answers
Yes this is possible using APEX Trigger on before Insert or before Update operation. Using the same above formula you can update the field in the Trigger.
Other workaround can be using the Formula field itself rather than using APEX trigger.
Please let me know if any concerns.
Thanks,
Jainam Contactor,
Salesforce Consultant
Varasi LLC
www.varasi.com
Helper Class
I have tried both methods, (a) setting default value and (b) Apex trigger and it works