+ Start a Discussion
Soundar Raj PonpandiSoundar Raj Ponpandi 

How to map CurrencyIsoCode in apex class ?

Hi,

I have enabled multi currecny in my organisation.

1. I like to map "CurrencyIsoCode" in apex class. But it's not mapping, let's say for example i am selected a value from currency dropdown as USD in a lead object (Custom Object).

2. While convert to opportunity lead currecncy should map with opportunity currecncy. but always it's taking a corperate currecny.

3. Can you please give me a valid suggestion why this multi currecny is not mapping in apex code.
 
opportunity.CurrencyIsoCode = leadRecord.CurrencyIsoCode;
insert opportunity;

Thanks and Regards,
Soundar Rajan P.
ShirishaShirisha (Salesforce Developers) 
Hi Soundar,

Greetings!

As far as I know,the provided format is the correct way of mapping the CurrencyISOCode but not sure,why this is not working as expected.

Reference:https://salesforce.stackexchange.com/questions/28595/opportunity-currencyisocode-equal-to-account

Also,please check the sample code for after trigger to update the Opportunity field and add the above logic in the trigger to see,if it works.

https://blog.jeffdouglas.com/2009/02/13/enhancing-the-lead-convert-process-in-salesforce/

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

 
Soundar Raj PonpandiSoundar Raj Ponpandi
HI Shirisha,

CurrencyISOCode is not working for my code,  Please review and correct me if i did any mistake.
 
public static Id convertToOpportunity(GD_Lead__c leadRecord) {
        Opportunity opp = new Opportunity();
        opp.GD_Lead__c = leadRecord.Id;
        opp.Name= leadRecord.name;
        opp.stageName = 'Qualification';
        Opp.CloseDate = Date.Today().addDays(30);
        opp.CurrencyIsoCode = leadRecord.CurrencyIsoCode;
        system.debug('Opp ' + opp.CurrencyISOCode + ' Lead ' + leadRecord.CurrencyISOCode);
        insert opp;
        return opp.id;
}

Else should i create any ticket for salesforce ?

Regards,
Soundar.