Aggregate queries and multicurrency

  • 1
  • Problem
  • Updated 3 years ago
  • In Progress
I'm building a chart based on an aggregate of a currency field, showing a total currency amount across some rows that have been grouped by type.

Unfortunately, all the figures are wrong. They don't add up with the currency amounts displayed for the rows in a table. 

It turns out that Salesforce has a "feature" that when you do an aggregate query on a currency field in a multicurrency org, the aggregated currency field is returned in the org's default currency, instead of the user's currency. 

https://developer.salesforce.com/forums/?id=906F00000008y4vIAA

There is a solution in the discussion above that involves querying the conversion rate yourself and applying it. I would do that if I was working in Apex, but can I do the same thing in a Skuid page? I suspect it would delay displaying the dashboard if I did it client-side. 

Would it be possible for you to do this conversion server-side and return an extra field in the aggregate model with the aggregated currency fields in the user's currency?
Photo of Ryan Paddy

Ryan Paddy

  • 578 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Alternatives:
- Write this custom query and include it in Skuid as a REST API model. 
- Or maybe you can directly query the users currency and the currency conversion rate (I really don't know if that is accessible).  And then do a UI Only field in your aggregate to lookup the conversion rate in the second model and do the rate calculation. 

Ideas,  just ideas. 
Photo of Ryan Paddy

Ryan Paddy

  • 578 Points 500 badge 2x thumb
Thanks Rob, those are good thoughts and if I find a work-around I'll post it back here. 

I wonder how much of a niche case this is, aggregate dashboards for currency fields in a multi-currency org? If it's something people hit reasonably frequently, it might be nice for Skuid to improve on Salesforce's rather broken functionality. I know I've worked in a lot of multi-currency orgs, probably about half the projects I've done.