I am getting a syntax error that I cannot figure out. can you help? trigger create_unique_name on hpzaccount__c ( before insert, before update) { List< hpzaccount__c > hpzlist = new List< hpzaccount__c >{}; //Loop through all records in the Trigger.new collection for(hpzaccount__c hpza : Trigger.new){ //Concatenate fields to list hpzlist.name = hpza.name; hpzlist.name_unique__c = hpza.name; }Insert hpzlist; }
2 respostas

Hi Howard, But this is bulk trigger
trigger create_unique_name on hpzaccount__c (before insert, before update) {
for (hpzaccount__c hpza : Trigger.new){
hpza.name_unique__c = hpza.name;
}
}
In this trigger you can not perform any dml/soql. In before trigger action you can change field value without dml on trigger objects.
Thanks,Alex