You need to sign in to do that
Don't have an account?

Trigger problem
I am attemtping to use the trigger.old to compare the previous owner value to the new owner value. However in the code below t.owner in null.
any assistance would be greatly appreciated
for (Task t : Trigger.new) {
system.debug('NEW OwnerID' + t.Owner);
if(t.Owner != null && System.Trigger.oldMap.get(t.id).Owner == t.Owner){
Map<Id, Contact> contacts = new Map<Id, Contact> ([Select Id, Phone, MobilePhone, Status__c, RecordTypeId, AccountId, LeadSource, Last_Comment__c
From Contact
Where Id IN :contactIds]);
Map<Id, Contact> desiredContacts = new Map<Id, Contact> ();
for (Contact c : contacts.values()) {
if (RecordType == '012U0000000L2TJIA0'&& c.Status__c == 'Prospect: Not Contacted' ) { //Call
c.Status__c = 'Prospect: Contacted';
desiredContacts.put(c.Id, c);
}else if (RecordType == '012U0000000XcyZIAS' && c.Status__c == 'Candidate: Qualified') { //Meeting
c.Status__c = 'Candidate: Meeting';
desiredContacts.put(c.Id, c);
//Meeting //Prospect
}
if (Trigger.isInsert) {
if (RecordType == '012U0000000XcyZIAS' && c.RecordTypeId == '012U0000000Y3ybIAC' && c.Status__c != 'Candidate: Qualified') { /// 02-12-2013 lreed...If user has not qualified lead show error message
trigger.new[0].adderror('You Must Qualify The Candidate Before Logging A Meeting!');
}else if (RecordType == '012U0000000XcyZIAS' && c.RecordTypeId == '012U0000000Y3ybIAC' && c.Status__c != 'Prospect: Contacted')
{ /// 02-12-2013 lreed...If user has not qualified lead show error message
trigger.new[0].adderror('Please Log a Call Before Qualifying The Candidate!');
}
}
}
hi,
Try to use OwnerId instead of Owner in your trigger.
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
'OwnerId' should be used in place of 'Owner'
Hello and Thank You
Now I am receiving "System.NullPointerException: Attempt to de-reference a null object: Trigger.CandidateStatusFlow: line 59, column 1"
The following is line 59. I believe it has something to do with "System.Trigger.oldMap.get(t.id).OwnerID"
"if(t.OwnerID != null && System.Trigger.oldMap.get(t.id).OwnerID == t.OwnerID){"
Hi,
Add one more condition in this line.
"if(t.OwnerID != null && System.Trigger.oldMap.get(t.id).OwnerID != null && System.Trigger.oldMap.get(t.id).OwnerID == t.OwnerID){"
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
Still receiving the same error message
Event should not be insert if you are using trigger.oldMap
if(t.OwnerId != null && (trigger.isUpdate && System.Trigger.oldMap.get(t.id).OwnerId == t.OwnerId)){
Nesha
That is right! After make this last change the error is gone, however the condition never evaluates to true. I have verified that the t.OwnerId is not null.
However when I try to use system.debug to see th value of "System.Trigger.oldMap.get(t.id).OwnerId", I receive the null pointer error.