Skip to main content
added 65 characters in body; edited tags; edited tags
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

I need a little help . I am almost there ... but need a little hand-holding. Agenda is to ALWAYS display the value converted in EUR - does not matter what the record currency is.

I am using this code below:

trigger convertToEuro on CustomObject(before update) { 
    List<CurrencyType> currencyTypeList = [select id,IsoCode,ConversionRate from CurrencyType where isActive = true] ;

    Map<String , Decimal> isoWithRateMap = new Map<String, Decimal>();

    for(CurrencyType c : currencyTypeList) {

        isoWithRateMap.put(c.IsoCode , c.ConversionRate) ;

    }

     

    for(CustomObject ce: trigger.new){

        if(ce.CurrencyIsoCode != 'EUR' && isoWithRateMap.containsKey(ce.CurrencyIsoCode)){

            ce.Amount_Converted__c = ce.ffps_iv__Amount__c/ isoWithRateMap.get(ce.CurrencyIsoCode);

        } 

    }
}

It is doing everything fine except the fact that the Amount_Converted__c field's values are displayed as USD (& EUR) but EUR seems like display only value - the USD is what the Amount_Converted__c field is holding. I want to use Amount_Converted__c converted in EUR in my workflow but instead I am getting the USD value - how could I just get the EUR value? I don't really need the Record Currency type - I need my EUR currency to be used in my workflows/approvals. 

enter image description here

Please help! Or atleast guide me on whatWhat could I ambe doing wrong?

I need a little help . I am almost there ... but need a little hand-holding. Agenda is to ALWAYS display the value converted in EUR - does not matter what the record currency is.

I am using this code below:

trigger convertToEuro on CustomObject(before update) { 
List<CurrencyType> currencyTypeList = [select id,IsoCode,ConversionRate from CurrencyType where isActive = true] ;

Map<String , Decimal> isoWithRateMap = new Map<String, Decimal>();

for(CurrencyType c : currencyTypeList) {

    isoWithRateMap.put(c.IsoCode , c.ConversionRate) ;

}

 

for(CustomObject ce: trigger.new){

    if(ce.CurrencyIsoCode != 'EUR' && isoWithRateMap.containsKey(ce.CurrencyIsoCode)){

        ce.Amount_Converted__c = ce.ffps_iv__Amount__c/ isoWithRateMap.get(ce.CurrencyIsoCode);

    }

}

It is doing everything fine except the fact that the Amount_Converted__c field's values are displayed as USD (& EUR) but EUR seems like display only value - the USD is what the Amount_Converted__c field is holding. I want to use Amount_Converted__c converted in EUR in my workflow but instead I am getting the USD value - how could I just get the EUR value? I don't really need the Record Currency type - I need my EUR currency to be used in my workflows/approvals.enter image description here

Please help! Or atleast guide me on what I am doing wrong?

I need a little help . I am almost there ... but need a little hand-holding. Agenda is to ALWAYS display the value converted in EUR - does not matter what the record currency is.

I am using this code below:

trigger convertToEuro on CustomObject(before update) { 
    List<CurrencyType> currencyTypeList = [select id,IsoCode,ConversionRate from CurrencyType where isActive = true] ;

    Map<String , Decimal> isoWithRateMap = new Map<String, Decimal>();

    for(CurrencyType c : currencyTypeList) {

        isoWithRateMap.put(c.IsoCode , c.ConversionRate) ;

    }

     

    for(CustomObject ce: trigger.new){

        if(ce.CurrencyIsoCode != 'EUR' && isoWithRateMap.containsKey(ce.CurrencyIsoCode)){

            ce.Amount_Converted__c = ce.ffps_iv__Amount__c/ isoWithRateMap.get(ce.CurrencyIsoCode);

        } 

    }
}

It is doing everything fine except the fact that the Amount_Converted__c field's values are displayed as USD (& EUR) but EUR seems like display only value - the USD is what the Amount_Converted__c field is holding. I want to use Amount_Converted__c converted in EUR in my workflow but instead I am getting the USD value - how could I just get the EUR value? I don't really need the Record Currency type - I need my EUR currency to be used in my workflows/approvals. 

enter image description here

What could I be doing wrong?

Source Link
Steve
  • 25
  • 2
  • 9

Salesforce Custom Currency Conversion Trigger

I need a little help . I am almost there ... but need a little hand-holding. Agenda is to ALWAYS display the value converted in EUR - does not matter what the record currency is.

I am using this code below:

trigger convertToEuro on CustomObject(before update) { 
List<CurrencyType> currencyTypeList = [select id,IsoCode,ConversionRate from CurrencyType where isActive = true] ;

Map<String , Decimal> isoWithRateMap = new Map<String, Decimal>();

for(CurrencyType c : currencyTypeList) {

    isoWithRateMap.put(c.IsoCode , c.ConversionRate) ;

}

 

for(CustomObject ce: trigger.new){

    if(ce.CurrencyIsoCode != 'EUR' && isoWithRateMap.containsKey(ce.CurrencyIsoCode)){

        ce.Amount_Converted__c = ce.ffps_iv__Amount__c/ isoWithRateMap.get(ce.CurrencyIsoCode);

    }

}

It is doing everything fine except the fact that the Amount_Converted__c field's values are displayed as USD (& EUR) but EUR seems like display only value - the USD is what the Amount_Converted__c field is holding. I want to use Amount_Converted__c converted in EUR in my workflow but instead I am getting the USD value - how could I just get the EUR value? I don't really need the Record Currency type - I need my EUR currency to be used in my workflows/approvals.enter image description here

Please help! Or atleast guide me on what I am doing wrong?