function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
StevevStevev 

UserInfo Multi Currency Org context

I have multiple orgs and want to be able to distinguish between single currency and multi currency org implementations. I'm using the UserInfo method "IsMultiCurrencyOrganization". I have a class and Apex code that works in a multicurrency org but the VF page won't compile when on a non multi currency org. It looks like the IsoCurrency field is not recognized which renders the whole idea of using the Boolean IsMultiCurrencyOrganization to test unworkable.

 

Anyone had experience with this problem?  The code example I used is below and has the following:

 

Custom Object:  Test_Userinfo__c with a single currency field called Payment__c

VF Page: UserInfoNew

Class: UserInfoExtension

 

The VF compile error:

Could not resolve field 'CurrencyIsoCode' from <apex:inputField> value binding '{!Test_Userinfo__c.CurrencyIsoCode}'    

 

 

public with sharing class UserInfoExtension {

Boolean multicurrency = false;

public UserInfoExtension(ApexPages.StandardController controller) {

}

Public Boolean getMultiCurrency() {

multicurrency = UserInfo.IsMultiCurrencyOrganization();

return multicurrency;

}
}

 

<apex:page standardController="Test_Userinfo__c"
extensions="UserInfoExtension">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!Test_Userinfo__c.Name}"/>
<apex:inputField value="{!Test_Userinfo__c.Payment__c}"/>

<apex:inputField value="{!Test_Userinfo__c.CurrencyIsoCode}" rendered="{!MultiCurrency}"/>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

SunnykoolSunnykool

Hi,

You are correct that you cannot use CurencyISOCode on Non Multi curency enabled orgs. But I can suggest you a solution for this.

 

Have this code snippet in some of your class

 

 

if(UserInfo.MultiCurrencyEnabled)

            sOQL query to fetch the active curreince from CurrencyType table

Define a list of select option in your controller ...List<selectOption>

Iterate the active currencies and store it in this SelectOption List and display that list in VF page

         Access that list in your VF Page.

 

}else{

    Nothing to do

}

 

 

Now for VF Page, display the picklist you made while iterating the currenices above.

Also, define a selectedCurrency variable to set it for a record in case its multi currency enabled.

 

Let me know in case you need any more info

 

Cheers

Jatin