Skip to main content Unisciti a noi al TDX, a San Francisco o su Salesforce+, il 5-6 marzo per la conferenza degli sviluppatori sull'era degli Agenti IA. Registrati ora.
V qr ha fatto una domanda in #Apex
Hi,

We have an object called "Project", and a project has its own currency, for instance ARS 

There are 2 Number Fields that we use to get the conversion Rate between "Project Currency", EUR and $

Exchange USD - Number Field (10,8)

Exchange EUR - Number Field (10-8)

We have a Trigger, to get the conversion Rate. 

User-added image

And we have Set Currency Exchange to 6 Decimal Places

But on "Exchange USD" and "Exchange EUR", Number are rounded to 2 Decimals.

Does anyone know how to avoid the rounded decimal to 2?

We need to see 8 decimals, not rounded.

Thanks,

V
3 risposte
  1. 18 dic 2017, 21:32
    Hi Guys, 

    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. 

    User-added image

    Please help. 

Caricamento in corso
0/9000