→ Apex Trigger 1 Develop an Apex Trigger so that every time any account is inserted then set the value of the Industry field to Education. Also, check if the Description is blank then set the value for the description field to “Account Description is blank”
Industry = Education
Description = Account Description is blankif Description is null
Hands on
//logic less trigger
trigger AccountTrigger on Account(before insert){AccountTriggerDispatcher.dispatch(Trigger.operationType);}
Dispatcher Class
// dispatcher classpublicclassAccountTriggerDispatcher{publicStaticvoiddispatch(System.TriggerOperation operationType){switch on operationType{
WHEN BEFORE_INSERT{AccountTriggerHandler.beforeInsert(trigger.new);}}}}
Handler Class
//Handler classpublicwithsharingclassAccountTriggerHandler{publicStaticvoidbeforeInsert(ListaccountList){for(Account acc : accountList){if(acc.Industry==Null){acc.Industry='Education';}if(acc.Description==Null){acc.Description='Account Description is blank';}}}}