+ Start a Discussion

Trigger Batch

I have a situation where I have writtena code where trigger works if we use trigger.new[0] but I want to standardise for multiple records and to try that I removed trigger.new[0] and made just trigger.new which throws a error can some one guide me how to use trigger.new without error
To handle bulk transactions, you'll want to loop over trigger.new  for example
trigger myTrigger on Case (before insert, before update) {
    for (Case c: trigger.new) {
        if (c.myVar__c == 'something') {
            c.myOtherVar__c = 'somethingelse';