I have written a method which I will call in a Trigger.While trying to save this code as Apex class, I am getting the error " Error: Compile Error: Loop variable must be of type SObject at line 7 column 13"
My code goes as below ,appreciate any help, thanks
public class LeadBefore {
public static void UpdateChapterEmailAddress (){
set<Id> JDRFLocationId = new set<Id>();
List<Lead> vLstLead = new List<Lead>();
for(Lead vLead:trigger.new)
{
if(vLead.JDRF_Location__c != null)
{
JDRFLocationId.add(vLead.JDRF_Location__c);
vLstLead.add(vLead);
}
}
Map<Id, JDRF_Location__c> vMapIdJDRFLocat = new Map<Id, JDRF_Location__c>([Select Id, Name, General_Email_Address__c from JDRF_Location__c where Id In: JDRFLocationId]);
for(Lead vLead: vLstLead)
{
if(vMapIdJDRFLocat.containsKey(vLead.JDRF_Location__c))
{
vLead.Chapter_Email_Address__c = vMapIdJDRFLocat.get(vLead.JDRF_Location__c).General_Email_Address__c;
}
}
}
}
trigger.new
list in an apex class.Lead
in addition to the standard Lead sObject?