You need to sign in to do that
Don't have an account?
Testing if an record exists getting System.NullPointerException
specificaly I am getting this erroe for line 3 column 1
Please note this is all a work in progress I am trying to move all of the related records to a lead that was created via a custom button thought I would start with the tasks.
trigger MigrateRelatedObjects on Contact (before delete)
{
for(Contact C: trigger.new)
if([select id from Lead where Old_Contact_ID__c = :C.id].size() > 0 )
{
For(Lead L:[select id from Lead where Old_Contact_ID__c = :C.id])
{List<Task> TaskToMove = new List<Task>();
{For(Task T:[select id, WhoID from Task where WhoID =:C.id])
{
T.WhoID = L.id;
TaskToMove.add(T);
}
{
}
}
}
}
}
Use Trigger.Old instead on Trigger.New
All Answers
Use Trigger.Old instead on Trigger.New
Thanks Bhawani,
I dont get a null error anymore, interestingly even after I added Update TaskToMove none of the tasks got re-parented.
Will have to look into this more, I really apreciate the help with the null issue.
R