I'm trying to create a trigger class that will clone an Opportunity that is of a certain record type and reaches a Stage that contains Close Won. Everything saves fine, but when I try to close out an Opp I get the error message:
System.NullPointerException: Attempt to de-reference a null object: Class.ClassRenewalOppClone.cloneOpp: line 8, column 1
Does anyone know why I might be getting this?
Trigger Class:
public class ClassRenewalOppClone {
public void cloneOpp(List<Opportunity> cloneOpp){
String recordTypeName = 'Renewals';
Map<String,Schema.RecordTypeInfo> rtMapByName = Schema.SObjectType.Campaign.getRecordTypeInfosByName();
Schema.RecordTypeInfo rtInfo = rtMapByName.get(recordTypeName);
id recType = rtInfo.getRecordTypeId();
FOR(Opportunity opp1 : cloneOpp){
IF(opp1.StageName.contains('Closed Won') && opp1.RecordTypeId == recType){
Before Update Trigger:
ClassRenewalOppClone updater4 = new ClassRenewalOppClone();
updater4.cloneOpp(Trigger.new);