Redeem Now
Read More
Read now
Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    How to get the default org currency in APEX

    Today we are going to discuss something about the Default currency of Salesforce org. As we all know that it is setup from Setup|Company Profile|Company Information for normal currency org. i.e. org without multi currency enabled. However sometimes we might need to fetch the data in APEX for creating applications. To get the data we cannot use any class or query for this purpose. Well the task is not as hard as it seems. And I’ll demonstrate it to you, how to get the default org currency in APEX.

    Apex Code

    We will be doing this task with the help of a standard class UserInfo. This class is used to get a lot of information for the user like getting the user’s first name, last name, organisation name, profile id of the user, time zone, username, email, etc. This class also has a function to get the org’s default currency of the organisation the user is working in. we are going to use the very same function for that purpose.

    And this is it, you can see it in the debug logs that the default currency is displayed. The currency that will be fetched will be in the ISO format, like INR for Indian Rupee, and USE for United state Dollar. The function helping us here to get the required data is the getDefaultCurrency() function. Now you can use it in your packages and send them in your apps to other orgs, and use the data by fetching it dynamically, instead of statically getting it.

    VF Page code

    As we can see that in the visualforce page we have just printed the org currency code that we got.


    The output of my code is something like this:


    That’s all about getting the default org currency in APEX, for any further queries feel free to add a ticket at:

    Or let us know your views on how to make this code better, in comments section below.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again

    Table of Content

    Hide Index