Change currency lookup using JavaScript

Dynamics 365 is a multi-currency system.  Each record can be configured to use a different currency if required.  To learn more about currency behaviour in Dynamics 365, check out this great article from Joel Lindstrom.  In this article, I will show you how to change the currency value and how to resolve one of the issues you may face when changing the currency value.

Change Currency Lookup

You can change the currency lookup (transactioncurrencyid) the same way you would change any other lookup value.

The issue with above solution is that while the currency lookup changes correctly, the currency symbol of currency type fields don’t change.  In this example, I have changed the currency from Australian dollar to Euro, but the symbol is still the ‘$’ symbol.

Incorrect currency symbol

While researching how to resolve this issue, I found an UNSUPPORTED solution.

This code uses undocumented methods and is not recommended.

Change Currency Symbol (Supported Method)

The best way to resolve this issue is by using Xrm.Page.data.refresh(true).  This function asynchronously refreshes and saves data on the form which changes the symbol to the correct one.

Pre-2013

If your system is older than Dynamics CRM 2013 then this method can’t be used.  You can use the below method to refresh the page.  The difference is this method is not asynchronous.  User will see the page is refreshing.

Conclusion

When changing currency lookup using JavaScript, you need to call;

to make sure the currency symbols of all currency fields are also change to the appropriate symbol.

Thank you for visiting Dyn365Apps.com.

Follow me on Twitter to get the latest news, tips and tricks and more …

Until next time…

[How To] Change currency and currency symbol using JavaScript
Tagged on: