You need to sign in to do that
Don't have an account?

How to return a list from a class to a trigger
Hello - How can I return a lead list called 'returnedLead' from a class to a trigger. Any assistance would be greatly appreciated.
Trigger:
if(Trigger.isUpdate){
//Passing Trigger.new and Trigger.old to LeadOwnerAssignment class
LeadOwnerAssignment.leadChanges(Trigger.new, Trigger.old);
}
Class:
public class LeadOwnerAssignment {
public static void leadChanges(List<Lead> newLead, List<Lead> oldLead){
List<Lead> returnedLead = new List<Lead>();
//Old Lead Map
Map<String, String> mapOfOldAffinityType = new Map<String, String>();
for(lead oldLds : oldLead) {
mapOfOldAffinityType.put(oldLds.Affinity_Type__c, oldLds.LastNameStreetAndZipCode__c);
}
for(Lead ld : newLead) {
if(ld.Affinity_Type__c != mapOfOldAffinityType.get(ld.Affinity_Type__c)){
returnedLead.add(ld);
}
}
}
}
Trigger:
if(Trigger.isUpdate){
//Passing Trigger.new and Trigger.old to LeadOwnerAssignment class
LeadOwnerAssignment.leadChanges(Trigger.new, Trigger.old);
}
Class:
public class LeadOwnerAssignment {
public static void leadChanges(List<Lead> newLead, List<Lead> oldLead){
List<Lead> returnedLead = new List<Lead>();
//Old Lead Map
Map<String, String> mapOfOldAffinityType = new Map<String, String>();
for(lead oldLds : oldLead) {
mapOfOldAffinityType.put(oldLds.Affinity_Type__c, oldLds.LastNameStreetAndZipCode__c);
}
for(Lead ld : newLead) {
if(ld.Affinity_Type__c != mapOfOldAffinityType.get(ld.Affinity_Type__c)){
returnedLead.add(ld);
}
}
}
}
Trigger
Class
All Answers
Trigger
Class
Class: