You need to sign in to do that
Don't have an account?
❤Code
trigger for auto number by record types
Hi,
I need to have a trigger on Account Object. My requirement is -
1. There is two recordtypes on account object acc1, acc2.
2. When i will create a record by select acc1, a custom field (account number ) should be updated with acc10001.
3. Similarly When i will create a record by select acc2, custom field (account number ) should be updated with acc20001 not by acc2002.
Kindly help.
Regards
I need to have a trigger on Account Object. My requirement is -
1. There is two recordtypes on account object acc1, acc2.
2. When i will create a record by select acc1, a custom field (account number ) should be updated with acc10001.
3. Similarly When i will create a record by select acc2, custom field (account number ) should be updated with acc20001 not by acc2002.
Kindly help.
Regards
for(account acc : trigger.new) {
if(acc.RecordType.name == 'acc1')
acc.accountNumber = acc.RecordType.name + '001';
else if(acc.RecordType.name == 'acc2')
acc.accountNumber = acc.RecordType.name + '002';
}
}
Mark it as best answer if it solves ur requirement.