
3 respuestas
Hi Roy try below code and let me know if it doesn't work
I tried it and it is working for metrigger updateRelatedRecords on Contact (before update) {
List<Case> caseList = new List<Case>();
List<Task> taskList = new List<Task>();
for(Contact con: trigger.new){
Contact con1 = trigger.old[0];
if(con1.AccountId != con.AccountId){
Task newTask = [Select Id from Task where WhoId =: con.Id limit 1];
newTask.WhatId = con.AccountId;
Case newCase = [Select Id from Case where ContactId =: con.Id limit 1];
newCase.AccountId = con.AccountId;
taskList.add(newTask);
caseList.add(newCase);
}
}
update taskList;
update caseList;
}