Sample Trigger:
Set < Id > setIds = new Set < Id >();
if(IsInsert || IsUpdate) {
for ( Task tsk : trigger.New) {
if ( tsk.WhatId.getSobjectType().getDescribe().Name == 'Accounts' )
setIds.add(tsk.WhatId);
}
}
List<Account> lAccount = [Select Id,description From Account where Id IN:setIds];
List<Account> UpdateAccount = new List<Account>();
for(Account a:lAccount){
a.description = 'Description Updated';
UpdateAccount.add(a);
}
update UpdateAccount;
}
No comments:
Post a Comment