8

Is there a way to check if an instance has Multi-Currency enabled through the API? I know that when enabling Multi-Currency, a CurrencyType object and multiple other fields are added on to each object.

Is there any other way other than querying for the CurrencyType object / CurrencyIsoCode on objects and then handling the INVALID_TYPE exception thrown when those fields are not in an instance without Multi-Currency enabled?

Thanks,

3 Answers 3

9
Boolean multiCurrencyEnabled = Schema.getGlobalDescribe().containsKey('CurrencyType');

If this check is true, it's safe to use CurrencyIsoCode fields and the CurrencyType object. I'd recommend using a static variable so it can be initialized just once per transaction.

6

Another possible way is via UserInfo Class.

Boolean multiCurrencyEnabled = UserInfo.isMultiCurrencyOrganization();

3

Thanks to sfdcfox for his answer in APEX. I was able to convert this into C# and here's what I got:

var currencyType = sForce.describeGlobal().sobjects.Where(x => x.name == "CurrencyType").FirstOrDefault();

It returs null if the org doesnt have multicurrency enabled and an initialized CurrencyType sObject if the org does.

1
  • I missed the C# flag, but yes, this is quite a bit easier than trying to catch exceptions.
    – sfdcfox
    Commented Oct 19, 2015 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .