You need to sign in to do that
Don't have an account?

calcualte users opportunity
Hi , i need to calculate the toal amount for closed/won opportunity amount for a particular user and display it in a field of custom object , where the custom object has look up relationship to the user, can any one help me how to do that
//(User) Kevin Peterson ==> 005d0000001TaWw (user ID)
Public List<Opportunity> closedWonAmountList = new List<Opportunity>();
Public Double TotalClosedWonAmount;
closedWonAmountList = [select Amount from opportunity where StageName='Closed Won' AND OwnerID = '005d0000001TaWw' ];
for(Opportunity opp : closedWonAmountList){
TotalClosedWonAmount = TotalClosedWonAmount + opp.Amount;
}
System.debug('Total Closed Won Amount of Kevin Peterson = ' +TotalClosedWonAmount );
All Answers
//(User) Kevin Peterson ==> 005d0000001TaWw (user ID)
Public List<Opportunity> closedWonAmountList = new List<Opportunity>();
Public Double TotalClosedWonAmount;
closedWonAmountList = [select Amount from opportunity where StageName='Closed Won' AND OwnerID = '005d0000001TaWw' ];
for(Opportunity opp : closedWonAmountList){
TotalClosedWonAmount = TotalClosedWonAmount + opp.Amount;
}
System.debug('Total Closed Won Amount of Kevin Peterson = ' +TotalClosedWonAmount );
perfect ,
Thanks a lot Ketan