Will the following trigger work ? – Salesforce Interview Question

Will the following trigger work ? – Salesforce Interview Question

Sample Code:


trigger tgrCounter on Mileage__c (after insert, after update) 
{
    List <Mileage__C> MilToupdate = new List<Mileage__C>();
    for(Mileage__cMlg : Trigger.new)
    {
        Mlg.Counter__c = Mlg.Counter__c + 1;
        MilToupdate.add(Mlg);
    }
    updateMilToupdate;
}

Answer:

No.
The reason is it will cause recursion.

Cheers!!!

Leave a Reply