You need to sign in to do that
Don't have an account?
Update task whoid on contact delete
For some reason this works fine when i replace the :C.ID with a hard coded ID.
I have used this method before but not with .old so I am wondering if that changes something.
trigger MigrateRelatedObjects on Contact (before delete)
{
for(Contact C: trigger.old)
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);
}
Update TaskToMove;
System.debug('Success');
}
}
}
else
{
System.debug('No Lead Found');
}
}
I ended up modifiying the code and running it from the lead.
Got the result I wa looking for.