This Trigger is on lead (Before Insert, Before Update) and it errors (System.NullPointerException: Attempt to de-reference a null object). I'm getting this error when i'm posting "Web to Lead". However i do have the right ORG iD and Record type id included on the xml file:
<input type=hidden name="oid" value="xxxxxxxxxxxxx"> <input type=hidden name="recordType" id="recordType" value="zzzzzzzzzzzzzzzzzz">
trigger IAAILeadTrigger on Lead (before insert, before update){
//BEGIN: S-444340 T-561808 - Process only IAA Remarketing Recordtype data
Map<ID,Schema.RecordTypeInfo> rt_Map = Lead.sObjectType.getDescribe().getRecordTypeInfosById();
//Looks up the branches based on the Lead PostalCode
if(trigger.isBefore){
for(Lead ld : trigger.new){
if (rt_map.get(ld.recordTypeID).getName().containsIgnoreCase('IAA Remarketing') )
if( trigger.isInsert ||
(trigger.isUpdate && ld.Branch__c == null) ||
(trigger.isUpdate && ld.PostalCode != trigger.oldMap.get(ld.id).PostalCode)
){
leads.add(ld);
}
}
}
//Only check the leads that are in the lead list and NOT the full trigger.new list
if(!leads.isEmpty()){
LeadController.GetLeadBranches(leads);
}
}
}
leads
?