Use before insert or before update if you need to update or insert the record on which you are writing the trigger.
Trigger populate_userlookup on Book__c (before insert, before update) {
for(Book__c b : Trigger.new) {
b.buyer__c = b.ownerId;
}
}
Note: No need to use DML statements like insert or update in case of before triggers.
Trigger populate_userlookup on Book__c (before insert, before update) {
for(Book__c b : Trigger.new) {
b.buyer__c = b.ownerId;
}
}
Note: No need to use DML statements like insert or update in case of before triggers.