When an Account is created and its Industry is set to “Media,” this trigger automatically sets the Rating to “Hot,” enforcing specific business logic for such accounts.
Learn more through this YouTube playlist.
Solution:
trigger AccountTrigger on Account (before insert) {
if(Trigger.isInsert){ if(Trigger.isBefore){
AccountTriggerHandler.updateRating(Trigger.New);
}
}
}
public class AccountTriggerHandler {
public static void updateRating(List<Account> accList){ for(Account acc:accList){
if(acc.Industry!=null && acc.Industry==’Media’){ acc.Rating=’Hot’;
}
}
}
}