Taking Multi-Currency in Salesforce.com to the Next Level
mgsmith | Sunday, January 25th, 2009 | 7 Comments »
Note: Post updated 28 Jan 2009 to include the trigger code discussed.
As SalesForce prepares the Spring ’09 release, I wanted to touch on what I think is an area they need to focus on – Currency Management.
In my opinion one of the biggest missing components of SalesForce.com has been around Currency Management, specifically around viewing amounts in different currencies using the correct exchange rate. Though SalesForce.com supports multi-currency and even added dated exchange rates in the Summer ’07, there are some severe limitations around this feature that can make it difficult for organizations to utilize Salesforce.com for more financial-type reporting.
From the SalesForce.com help on the advanced currency features:
Advanced Currency Management Considerations
|
The two big problems with the above are:
- Dated exchange rates only used on limited objects; specifically no custom objects.
- Roll-ups on the Opportunity currency fields no longer work.
If a company wanted to leverage the power of the SalesForce.com platform to use for a system that required more accurate currency reporting, such as a Project Accounting system, these are major limitations. Luckily, SalesForce.com does a great job listening to their customers. Searching through the posted ideas, I found some roughly similar thoughts, but nothing that specifically addressed dated exchange rates on custom objects. My long term preference for this is for SalesForce.com to add a Formula Function to convert any value to any currency using an effective date: ConvertCurrency(Amount, From_ISOCode, To_ISOCode, Effective_Date). I posted this idea on the Force.com Ideas board. If you agree with my recommendation, please review and promote my idea.
http://ideas.salesforce.com/article/show/10095125/Support_dated_exchange_rates_in_custom_objects
While we wait for SalesForce.com to address these issues in their base functionality, there is a way to work around this using Apex triggers. The general idea is to create converted currency field(s) on the necessary objects and use the trigger to update the values on these. I’ll avoid using code to keep the post short, but tThe functionality would work as follows. The trigger code can be found at the end of this post:
- Create an Amount_XXX (where Amount is a field name and XXX is the currency) field on objects where you need to be able to roll-up or display amounts in XXX currency using the dated exchange rate. For example, Amount_USD would contain the Amount field converted USD.
- Create an Insert/Update Trigger on the object to set this field value based on a specific date field on the object. The trigger would lookup the exchange rate based on a specific date field on the object, do the conversion and then update the Amount_XXX field
The key downside to this methodology is that you’d need to have one custom field (and field-specific trigger code) per field and currency that requires conversion. However, if you really must be able to roll-up, display, and/or report on a custom object using dated exchange rates this is a viable work-around.
Fixing the inherent problems with multi-currency would enable vendors to develop powerful financials related applications using the Force.com API. I’m not necessarily suggesting that the full financial software (AR, AP, GL) be moved to the SaaS model. That has its own set of potential problems – especially around auditing and security. What I am noting is that there are other uses for strong financial capabilities outside of the standard AR/AP/GL model. Even if you wanted to do something simple like generate Invoices from sold SalesForce.com Opportunities, not being able to track the exact amount invoiced in the correct currency is a big concern.
. .

Any chance you have the test code already written?
Ron,
There should be a test class in the Zip file.
Best regards,
Mike
Mike, I am not sure I see the Zip file. I’d love to get the copy of the test class as well.
Thanks,
Dmitri
Any specific reason you chose to go this route, rather than just store and updte a custom field Exchange Rate on the Order Record and do all conversions via formula fields?
Dmitri,
You’re correct. I could have setup a Trigger to store the Exchange Rate(s) in the object and used formulas for the values. The real caveat for this is you’d have to be sure that the Exchange Rate value never changes once it’s stored in the record, or build logic into the Triggers to handle that. If you’re talking about records in the future (like an Opportunity), the record rate will change every time the system rates are updated until the Close Date has passed.
Also, the Zip file is in the Source Code tab.
Best Regards,
Mike
What will be the type of field Amount_XXX?
Harshsesh,
In that example, Amount_XXX would probably be a numeric field (versus Currency).
Best Regards,
Mike