You need to sign in to do that
Don't have an account?
Roshni Rahul
To get the total sum of amount field in account object
Hi Team,
Need help.
My requirement is to get the total sum of amount field in account object from opportunity. what i have done is i have created a rollup summary in account object with child as opportunity. So i am getting the total amount of all opportunities associated with an account. Now i have to get total amount for all account. ie sum of the roll up summary. Is that possible..
Need help.
My requirement is to get the total sum of amount field in account object from opportunity. what i have done is i have created a rollup summary in account object with child as opportunity. So i am getting the total amount of all opportunities associated with an account. Now i have to get total amount for all account. ie sum of the roll up summary. Is that possible..
Please use the below trigger for your req
Use this class for avoiding recursive calling of above trigger,
Please note this calculates only the opportunities having an account. Other opportunities will be discarded
Regards
All Answers
[SELECT Name,CloseDate,amount,sum(account.Total_amount__c) FROM Opportunity]
but its throwing error. Can any one please help me.
Then do you also want to have this value on the opportunity to show the total-amount of the account it belongs to? This can be done with a formula field on the opportunity to populate the total-amount field of its account.
I hope this helps
I have already done what you have mentioned. My requirement is to get the sum of total-amount opportunity value of all accounts. For that I have used the query that i have posted above. But its throwing error while using the SUM.
...
AggregateResult[] groupedResults = [SELECT sum(Total_amount__c) sum FROM Account where account_type = customer];
grandTotal = double.valueOf(groupedResults[0].get('sum'));
Embed the above logic on your account trigger and save it on account on a field. You can use that field in your SOQL.
Please use the below trigger for your req
Use this class for avoiding recursive calling of above trigger,
Please note this calculates only the opportunities having an account. Other opportunities will be discarded
Regards
Thank you for your replies. Eldon's code is working fine for me.