Header Ads Widget

Currency Conversion Issue || interview stuff

Currency Conversion Issue


Requirement:  Need to populate the currency field value only in USD format.
Technical:
 We have requirement Currency field should populate the USD Dollar value only. When user create/update the record currency field take the value from users Currency like user from Germany and users Currency is EURO then user can see two values in Currency field of record like USD 5,645,646.00 (EUR 4,544,745.03) or EUR 4,544,745.03 (USD 5,645,646.00).
Solution:
  As above Currency Conversion issue Salesforce has provides the live value of Currency however limitation is Currency field of record will populate both the values.
 So we have overcome this issue from output visualforce page. Means we have done JavaScript code on page load and at the time of loading we convert the USD 5,645,646.00 (EUR 4,544,745.03) in to 5,645,646.00.
Below code explain the Currency in USD only and set to field in visualforce page.
JavaScript code in VF page:
        var QuoteValue= USD 5,645,646.00 (EUR 4,544,745.03);
        if(QuoteValue != null || QuoteValue > -1){      
        var a = (QuoteValue.indexOf("USD"))+3;
        var b = QuoteValue.length;
        if(QuoteValue.lastIndexOf(")")>-1){
            b=b-1;
        }
        var s=QuoteValue.slice(a,b);
        var s1=s.indexOf(".");
              s=s.slice(0,s1+3);
                        FieldValue = s;
       }

Post a Comment

0 Comments