convertCurrency()

Use convertCurrency() in a SOSL query to convert currency fields to the user’s currency. This action requires that the organization is multi-currency enabled.

Use this syntax for the RETURNING clause:

convertCurrency(Amount)

For example,

1FIND {test} RETURNING Opportunity(Name, convertCurrency(Amount))

If an org has enabled advanced currency management, dated exchange rates are used when converting currency fields on opportunities, opportunity line items, and opportunity history. With advanced currency management, convertCurrency uses the conversion rate that corresponds to a given field (for example, CloseDate on opportunities). When advanced currency management isn’t enabled, the most recent conversion date entered is used.

You can’t use the convertCurrency() function in a WHERE clause. If you do, an error is returned. Use the following syntax to convert a numeric value to the user’s currency from any active currency in your org.

1WHERE Object_name Operator ISO_CODEvalue

For example:

1FIND {test} IN ALL FIELDS RETURNING Opportunity(Name WHERE Amount>USD5000)

In this example, opportunity records are returned if the record’s currency Amount value is greater than the equivalent of USD5000. For example, an opportunity with an amount of USD5001 is returned, but not JPY7000.

Use an ISO code that your org has enabled and made active. If you don’t put in an ISO code, the numeric value is used instead of comparative amounts. Using the previous example, opportunity records with JPY5001, EUR5001, and USD5001 would be returned. If you use IN in a WHERE clause, you can’t mix ISO code and non-ISO code values.

Ordering is always based on the converted currency value, just like in reports. So, convertCurrency() can’t be used with the ORDER BY Clause.

Note

The convertCurrency() function supports aliasing. In addition, aliasing is required when the query includes the same field multiple times. For example:
1FIND {Acme} RETURNING Account(AnnualRevenue, convertCurrency(AnnualRevenue) AliasCurrency)