• Salesforce Consulting

Salesforce Triggeers

A developer has created the following trigger:

trigger ProcessDoNotCall on Contact (after update) List<Contact> lstCon = [SELECT Id, DoNotCall, Department FROM Contact WHERE Department = 'HR' AND Id IN :Trigger.new]; for(Contact c : lstCon) c.DoNotCall= true; update lstCon;

The developer executes the following code anonymously in the Saleforce

Developer Console. Assume that the record exists in Salesforce.

Contact con = new Contact(Id='003oOOOOOOVHXOm',Department = 'HR') update con;

Which behavior will the developer observe? A. The code will throw an exception because the maximum trigger depth has been exceeded. B. The code will throw an exception, saying that the record cannot be updated in an After Update trigger. C. The code will throw an exception in Anonymous Apex, indicating that the Id field is read-only. D. The contact record will be saved and the contact record's DoNotCall field will be set to true.

Discussion. The code will throw an exception can't update a record in after trigger scenario.

#consulting #salesforce


  • Salesforce Consultants
  • Salesforce Consultants
  • Salesforce Consultants