• Al Sugarman
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I created a number field that I am trying to populate with the USD amount of a currency field on opportunities. I have tried two methods but still the field display only the currecy thet the opportunity is in...any help is appreciated...

Method 1
trigger convertcurrency on Opportunity (before insert, before update) {
    for(Opportunity o :trigger.new){
        Boolean isChanged = false;
        if(trigger.isUpdate && o.Reporting_Total__c != trigger.oldMap.get(o.Id).Reporting_Total__c){
            isChanged = true;
        {
        Opportunity[] opps = [select convertCurrency(Reporting_Total__c) from Opportunity where Id = :o.Id];
                        o.Reporting_Total_in_USD__c = o.Reporting_Total__c;
                
        }
        }
    }
}

===============================================
Method 2
trigger convertcurrency on Opportunity (before insert, before update) {
    for(Opportunity o :trigger.new){
        Boolean isChanged = false;
        if(trigger.isUpdate && o.Reporting_Total__c != trigger.oldMap.get(o.Id).Reporting_Total__c){
            isChanged = true;
        {
        
        For (AggregateResult[] opp : [select name, SUM(Reporting_Total__c) rt from Opportunity where id = : o.id  group by Name ])
        
        for(AggregateResult ar : opp){
        
                        o.Reporting_Total_in_USD__c = o.Reporting_Total__c;
                                      }
        }
    }
}
}
 
I created a number field that I am trying to populate with the USD amount of a currency field on opportunities. I have tried two methods but still the field display only the currecy thet the opportunity is in...any help is appreciated...

Method 1
trigger convertcurrency on Opportunity (before insert, before update) {
    for(Opportunity o :trigger.new){
        Boolean isChanged = false;
        if(trigger.isUpdate && o.Reporting_Total__c != trigger.oldMap.get(o.Id).Reporting_Total__c){
            isChanged = true;
        {
        Opportunity[] opps = [select convertCurrency(Reporting_Total__c) from Opportunity where Id = :o.Id];
                        o.Reporting_Total_in_USD__c = o.Reporting_Total__c;
                
        }
        }
    }
}

===============================================
Method 2
trigger convertcurrency on Opportunity (before insert, before update) {
    for(Opportunity o :trigger.new){
        Boolean isChanged = false;
        if(trigger.isUpdate && o.Reporting_Total__c != trigger.oldMap.get(o.Id).Reporting_Total__c){
            isChanged = true;
        {
        
        For (AggregateResult[] opp : [select name, SUM(Reporting_Total__c) rt from Opportunity where id = : o.id  group by Name ])
        
        for(AggregateResult ar : opp){
        
                        o.Reporting_Total_in_USD__c = o.Reporting_Total__c;
                                      }
        }
    }
}
}