You need to sign in to do that
Don't have an account?
MaggieSumit
I getting null value on final map In trigger
trigger AppLeadCreation on alu_Application__c (before insert, before update) {
// SOQL QUERY FOR ITERATES
Map<Id,Lead> mapLeads = new Map<Id,Lead>([SELECT Id, Email FROM Lead]);
System.debug('mapLeads'+mapLeads);
// MAP OF IDs AND EMAIL ADDRESS OF LEAD
Map<String,Id> mapIdsWithLeadEmail = new Map<String,Id>();
// MAP OF IDs AND EMAIL ADDRESS OF APPLICATION
Map<String,Id> mapIdsWithAppEmail = new Map<String,Id>();
// MAP OF LEAD IDs AND APPLICATION ID
Map<Id,Id> mapAppIdsEmailIds = new Map<Id,Id>();
for(Lead le : mapLeads.values()){
mapIdsWithLeadEmail.put(le.email, le.Id);
}
System.debug('mapIdsWithLeadEmail'+mapIdsWithLeadEmail);
for(alu_Application__c app : trigger.new){
mapIdsWithAppEmail.put(app.Email__c, app.Id);
}
System.debug('mapIdsWithAppEmail'+mapIdsWithAppEmail);
try{
for(Id tmp : mapIdsWithAppEmail.Values()){
if(mapIdsWithLeadEmail.ContainsKey(mapIdsWithAppEmail.get(tmp))){
mapAppIdsEmailIds.put(tmp,mapIdsWithLeadEmail.get(tmp)); //Here I getting only ID of Application record not for Lead
}
}
System.debug('mapAppIdsEmailIds'+mapAppIdsEmailIds);
}Catch(Exception e){
System.debug('ERROR:' + e.getMessage());
System.debug('ERROR:' + e.getLineNumber());
}
}
// SOQL QUERY FOR ITERATES
Map<Id,Lead> mapLeads = new Map<Id,Lead>([SELECT Id, Email FROM Lead]);
System.debug('mapLeads'+mapLeads);
// MAP OF IDs AND EMAIL ADDRESS OF LEAD
Map<String,Id> mapIdsWithLeadEmail = new Map<String,Id>();
// MAP OF IDs AND EMAIL ADDRESS OF APPLICATION
Map<String,Id> mapIdsWithAppEmail = new Map<String,Id>();
// MAP OF LEAD IDs AND APPLICATION ID
Map<Id,Id> mapAppIdsEmailIds = new Map<Id,Id>();
for(Lead le : mapLeads.values()){
mapIdsWithLeadEmail.put(le.email, le.Id);
}
System.debug('mapIdsWithLeadEmail'+mapIdsWithLeadEmail);
for(alu_Application__c app : trigger.new){
mapIdsWithAppEmail.put(app.Email__c, app.Id);
}
System.debug('mapIdsWithAppEmail'+mapIdsWithAppEmail);
try{
for(Id tmp : mapIdsWithAppEmail.Values()){
if(mapIdsWithLeadEmail.ContainsKey(mapIdsWithAppEmail.get(tmp))){
mapAppIdsEmailIds.put(tmp,mapIdsWithLeadEmail.get(tmp)); //Here I getting only ID of Application record not for Lead
}
}
System.debug('mapAppIdsEmailIds'+mapAppIdsEmailIds);
}Catch(Exception e){
System.debug('ERROR:' + e.getMessage());
System.debug('ERROR:' + e.getLineNumber());
}
}
Let us know if this will help you