5

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,

5
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.

2

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.

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

Another possible way is via UserInfo Class.

Boolean multiCurrencyEnabled = UserInfo.isMultiCurrencyOrganization();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.