+ Start a Discussion

Adding different currency amounts in Trigger

I have a trigger in my production environment which I just realized sums Opportunity Amounts irrespective of currency. For example, "AUD 150" plus "NZD 100" equals "AUD 250". I have set the NZD currency to be lower in the "Manage Currencies" section, but how can I incorporate the currency differences in the code? Below is a snapshot of my current code (that doesn't factor in the currency).


 //Loop through the opportunity records
    for (Opportunity opp : opps) {
      if (opp.Amount != null) {
        Decimal totalAmount = 0.00;
        if (totalAmountMap.get(opp.Master_Lease_Agreement__c) != null)
          totalAmount += totalAmountMap.get(opp.Master_Lease_Agreement__c);


You can refer the field CurrencyIsoCode, and while creating the map, take that into considertion.


Hi Prasanna, thanks for that. Can you please give me an example, or point me to an example? It's difficult for me to start from scratch.