Trigger
mysql> SET @sum = 0;
mysql> INSERT INTO account VALUES(137,14.98),(141,1937.50),(97,-100.00);
mysql> SELECT @sum AS 'Total amount inserted';
+-----------------------+
| Total amount inserted |
+-----------------------+
| 1852.48 |
+-----------------------+
Trigger
trigger OppoRecordUpdate on Account (After insert, After update) {
List newlist = new List();
Set newset = new Set();
for(Account acc : Trigger.new){
newset.add(acc.Id);
}
List Acclist = [Select Id,Name,(Select Id,Name From Contacts) From Account Where Id =: newset];
for(Account ac : Acclist){
for(Opportunity opp : ac.Opportunities){
opp.Description = ac.Description;
newlist.add(opp);
}
}
update newlist;
}
|