Skip to main content
5 Antworten
  1. Gestern 05:48

    Hi @Hitesh Sharma 

     

    Yes, a trigger can perform DML on the same object, but it depends on the trigger context.

    For example, in an after update Account trigger:

    trigger AccountTrigger on Account (after update) {    for (Account acc : Trigger.new) {        acc.Description = 'Updated';    }    update Trigger.new;}

    This update causes the Account trigger to fire again, which can lead to recursive execution and eventually a Maximum trigger depth exceeded error.

    Also, in a before trigger, we normally modify Trigger.new directly without performing DML, because Salesforce automatically saves those changes as part of the original transaction.

    So the best practice is: avoid unnecessary DML on the same records and use appropriate recursion-control logic when same-object updates are required.  

     

    Hope This Helps!!.

0/9000