You need to sign in to do that
Don't have an account?

Query fields dependent on UserInfo variable.
How to query CurrencyISOCode in SOQL when organization is Multi Currency (UserInfo.isMultiCurrencyOrganization) and don't query that otherwise, and in the same query filter by an array of ids (...where id in :ids )?
pseudo-code
if(UserInfo.isMultiCurrencyOrganization == true){
//soql statement that includes the currencyIsoCode field in the where clause
else{
// soql statement that does not include the currencyIsoCode field in the where clause
}
This solution doesn't do it in one single line of code, but it still will only execute 1 SOQL statement in either case.
I hope this helps.
Lets go with this approach.
1. Do a Describe on the object for which you want to query
2. Check the Describe Results to see if there is a field 'currencyIsoCode'
3. If yes, add it to the where clause as needed.
4. Use Dynamic SOQL to query.
Here is a link to more information on Dynamic Apex : http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_dynamic.htm
It involves a little more code than our previous solution (which is invalid regardless), but this should resolve your requirement and support if multi-currency is enabled or not.
Thanks,
Andrew
When I loop through rows selected without the currency code ( array of ids is in the where clause ) i call database.query where i search for a record with the particular actual being looped id, and then i take element [0] and using sObject.get i take the value.
Nasty and maybe vurnalable code but what to do... ;)