I am new to the world of triggers.I have a custom object customer
and if some condition is satisfied, i would like to insert fields from customer
to accounts
. how do i do that?i did the following but it says
Error: Compile Error: unexpected token: 'for' at line 6 column 6 :
trigger CustomerTrigger on Customer__c (before insert) {
List<Account> acct = new List<Account>
//Trigger.new Represents a list of Customer records you are trying to insert.
//So iterate the list in a for loop
for (Customer__c newCustomerRecord: Trigger.new) {
//Check if the Customer belongs to a Key Account
if(newCustomerRecord.Key_Account__c){
acct.add(new Account(
Customer_Name_c = newCustomerRecord.Customer_Name_c,
Customer_Address_c = newCustomerRecord.Customer_Address_c));
}
}
insert acct;
}