I have Contact records - of RecordType = AiM CR Writer - that when created I want the Account Name to automatically populate with a specific account. Here's the trigger I've written so far...This works, but I'd like to use a variable for the accountid so I don't have to hard code it. Is there a way to do this? Thanks
// if this is an AiM CR Writer contact then populate customer name to AiM CR Writer Master Customer
trigger UpdateCRWriterMasterCustomer on Contact (before insert) {
Id rtId1 = [select Id,name from RecordType where name='AiM CR Writer' and SObjectType='CONTACT' limit 1].id;
for (Contact cont : Trigger.new) {
If (cont.RecordTypeId == rtId1 ){
for (Contact c1 : Trigger.new){
c1.accountid = '001e000000Vw5Pb';
}
}
}
}