There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was:
Apex trigger updatequotestatus caused an unexpected exception, contact your administrator: updatequotestatus: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.updatequotestatus line 5, column 1.
Error Occured at Line:
if((t.what.getsobjecttype() == quote__c.sobjecttype) && (t.subject.substring(0,5) == 'Email')
trigger updatequotestatus on task (after insert, after update){
Set<Id> quoteIds = new Set<Id>();
List<quote__c> quotes = new List<quote__c>();
for(task t:trigger.new){
if(t.whatId!=null){
if((t.what.getsobjecttype() == quote__c.sobjecttype) && (t.subject.substring(0,5) == 'Email')){
quoteIds.add(t.whatId);
}
}
}
for(quote__c q:[select StageName__c from quote__c where Id IN : quoteIds]){
quote__c qt = new quote__c();
qt.Id = q.Id;
qt.StageName__c = 'Proposal Sent';
quotes.add(qt);
}
if(quotes.size()>0){
update quotes;
}
}
if((t.what.getsobjecttype()==quote__c.sobjecttype) && (t.subject.substring(0,5)=='Email')
so I suggest you do some debugging (e.g. printout the value oft.what
) to see what is null in that line