function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AndrewFisher_TGPAndrewFisher_TGP 

AggregateResult & Currency support

Hello one and all, and Merry Christmas (or Happy Holidays).

 

I have an issue with some code I have written that uses AggregateResult (SUM) function, the code is totalling the sum back to the org default currency (which is what is stated in the help documentation).  My issue is when placing the amount totalled back into a currency field on a record with a different currency.

 

So say (hypothetically - for arguments sake lets say that it is £1=$2 conversion rate):
Acct A = US$10 (£5)
Acct B = US$6 (£3)
 
The total should obviously be = US$16 (£8).  The total it is showing is US$ 8 - so it converts the figures into GBP values,  totals the values and then puts this amount into the currency field - though the field is showing the wrong currency code as the account currency is USD.
 
If there is an account that is in GBP - there is no issue though - so yay :-)
 
Is there a way to take the figure that the aggregateresult figure and then convert it back to the account currency?
Best Answer chosen by Admin (Salesforce Developers) 
AndrewFisher_TGPAndrewFisher_TGP

For anyone else with similar issue I think I found a possible answer based on the following link:

http://boards.developerforce.com/t5/Formulas-Validation-Rules/Foreign-currency-conversion-formula/td-p/31174

 

Also found the CurrencyType methods *DOH*

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_currencytype.htm