+ Start a Discussion
UpendraUpendra 

Currency getting converted into Organization default currency while using aggregate SOQL

Hi All,

I'm my code I have a aggregate SOQL on currecny field, which always provides me the result in Organization default currecny(in USD). After some reaching I found there is a manual way to solve the issue ( https://developer.salesforce.com/forums?id=906F00000008y4vIAA ). In my application there are many places where we are having this issue.

So, is it possible to use "convertCurrency" function to restrict the conversion to org default?
 
SwarnaSankhaSinghSwarnaSankhaSingh

Hi Upendra,

The convertCurrency() in the SELECT statement of a SOQL query is used to convert currency fields to the user’s currency. You cannot convert the result of an aggregate function into the user’s currency by calling the convertCurrency() function.

If a query includes a GROUP BY or HAVING clause, currency data returned by using an aggregate function, such as SUM() orMAX(), is in the org’s default currency.

You can refer to the following document https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_querying_currency_fields.htm

Please do let me know if you need any further clarification. If you feel that your question was answered then do flag the appropriate answer as the solution to your query.

Kind Regards,
Swarna.

UpendraUpendra
Hi Swarna,

Thanks for making some time and replying to this post.

Actually I have already went through the document, but it's very confusing. 

My issue is: The field has stored currency values as EUR, while using aggregate query to get sum of the currecny amount I'm expecting it to be in EUR but Salesforce automatically converts it to USD(Our corporate currecny) which I don't want.

So, how I can block it? or any easiest way to get the amount in EUR instead of USD?