This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AccountTrigger on Account (before update){ | |
//更新された全取引先に紐づく成立商談の金額を集計 | |
for(Account acc:[SELECT Id,amountSum__c, | |
(select id,amount from Opportunities | |
where isWon = true) | |
FROM Account | |
WHERE Id IN :Trigger.New]){ | |
Decimal amountSum = 0; | |
for(Opportunity opp:acc.Opportunities){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AccountTrigger on Account (before update) { | |
//更新された取引先に紐づく商談を取得 | |
List<Opportunity> opportunities = [SELECT id,Amount | |
FROM Opportunity | |
WHERE AccountId=:Trigger.New[0].Id]; | |
//Trigger.New[0]なので更新された1レコード目に関する処理のみしか実施されない。 |
NewerOlder