function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PProkesPProkes 

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);

_Prasu__Prasu_

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

PProkesPProkes

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.