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

Comparing currency field with a dollor value in an if statement
Hi,
I have a currency field on opportunity calles Currency1__c which can be any currency type(Multi-currency organization).
I want to compare this field with 700USD value
if(opptyrecord.Currency1__c > 700USD){
}
If Currency1__c is coming in INR, it should convert and compare with dollor value.
Please help in getting solution for this.
Thanks in advance
I have a currency field on opportunity calles Currency1__c which can be any currency type(Multi-currency organization).
I want to compare this field with 700USD value
if(opptyrecord.Currency1__c > 700USD){
}
If Currency1__c is coming in INR, it should convert and compare with dollor value.
Please help in getting solution for this.
Thanks in advance
You need to perform conversion before doing any operation in your code. Achieve this by using currencyType sobject in your ORG.
Exchange rates are stored in CurrencyType Sobject. Refer below link for info on currencyType
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_currencytype.htm (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_currencytype.htm" target="_blank)
For every multi currency ORG there will be a corporate currency. All exchange rates are calculated against this corporate currency.
So now let's assume USD is your corporate currency.
Query conversion rates and put it in a map get current objects ISO code
If that helps mark this as Best answer. It will help others.
All Answers
Thank you for your valuable time. I need to use this logic in apex code , not in any formula. And also value can come in any currency type.
account acc = [select id, convertCurrency(AnnualRevenue) from account where id = '00190000014Ljyq'];
system.debug(acc.AnnualRevenue);
You need to perform conversion before doing any operation in your code. Achieve this by using currencyType sobject in your ORG.
Exchange rates are stored in CurrencyType Sobject. Refer below link for info on currencyType
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_currencytype.htm (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_currencytype.htm" target="_blank)
For every multi currency ORG there will be a corporate currency. All exchange rates are calculated against this corporate currency.
So now let's assume USD is your corporate currency.
Query conversion rates and put it in a map get current objects ISO code
If that helps mark this as Best answer. It will help others.