Created
December 7, 2023 00:48
-
-
Save kamalpreet-rad/ec7b93e7e1103f5645a9b1edf493f2d1 to your computer and use it in GitHub Desktop.
Week 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger LeadTrigger on Lead (after insert, after update) | |
{ | |
if(Trigger.isAfter) | |
{ | |
if(trigger.isInsert) | |
{ | |
LeadHandlerClass.CreateTask(Trigger.New,Null); | |
} | |
if(Trigger.isUpdate) | |
{ | |
LeadHandlerClass.CreateTask(Trigger.New,Trigger.oldMap); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LeadHandlerClass | |
{ | |
Public Static Void CreateTask(List<Lead> Listofleads, Map <Id, Lead> OldLeadMap) | |
{ | |
List<Task> newlistoftasks = new List<Task>(); | |
for(Lead ld : Listofleads) | |
{ | |
if( ld.ProductInterest__c !=null && (OldLeadMap == null || ld.ProductInterest__c != OldLeadMap.get(ld.id).ProductInterest__c)) | |
{ | |
Task t = new Task(); | |
t.Subject = 'Follow With New Lead'; | |
t.Status = 'Not Started'; | |
t.WhoId = ld.Id; | |
newlistoftasks.add(t); | |
} | |
If(!newlistoftasks.isEmpty()) | |
{ | |
insert newlistoftasks; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment