New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :https://t.co/p4F3oeQagK

Saturday, 16 February 2013

Update a record on which we are writing the trigger

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.

No comments:

Post a Comment

Labels