This trigger updates specific fields (Lead Source, SIC Code, and Primary) for Leads in the Healthcare industry when their records are updated. It enforces industry-specific field values and improves data consistency.
For more practice scenarios, explore this YouTube playlist.
Solution:
trigger LeadTrigger on Lead (before update) {
if(Trigger.isBefore && Trigger.isUpdate) {
for (Lead leadRec : Trigger.NEW) {
leadRec.Status=’Working-Contacted’;
if (leadRec.Industry == ‘Healthcare’) {
leadRec.LeadSource = ‘Purchased List’;
leadRec.SICCode__c = ‘1100’;
leadRec. Primary__c = ‘Yes’;
}
}
}
}