2

I have a custom object "Sales Order" which is master and i have custom object "Invoice" which is child.It has lookup relation ship.I have written a rollup summary using trigger as it has lookup relationship.Invoices can have multiple currency.So i need to get roll up summary field with multi currency support.is it possible to get sum of amount of all invoices in converted currency. below is my code snippet :

Decimal Sum;
            for(Sales_Quota__c objSalesQuota : [select Id,Actuals__c,(select Id,convertCurrency(Total_Price__c) from Invoices__r) from Sales_Quota__c where Id IN: salesQIds]){
                Sum=0;
                for (Invoice_CU__c objInv:objSalesQuota.Invoices__r){
                    Sum+= objInv.Total_Price__c;
                }
                objSalesQuota.Actuals__c = Sum;
                salesQuotaList.add(objSalesQuota);
            }
            try{
                update salesQuotaList;
            }Catch(Exception e){
                System.debug('Exception :'+e.getMessage());
            }

When it sums up it is not in converted currency.

  • So, the user is not able to see the summed up price in their own locale right? For eg. if the sum is USD500, the UK user should see it GBP385.31. But it's not happening. Correct? – Shailesh Patil Jul 11 '16 at 13:44
1

In a multi-currency org, all opportunities are stored in the org's default currency. It's simply a case of opportunities being entered in a user's default currency. However, once entered, they should be converted to the org's default currency using either the current conversion rate or the dated conversion rate if advance currency management is enabled. See Implications of Enabling Multiple Currencies for more on this.

If you want to see the roll-ups in your converted currency, you'll need to create a page that converts them to that currency after each rollup calculation. You may want to create some custom apex or formula fields that automatically do this for you for use with that page.

EDIT

After looking at your code, I see you're using queries. See Querying Currency Fields in Multi-currency Orgs. The following syntax is for using convertCurrency() with the SELECT clause: convertCurrency(field)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.