Display Currency Values Based on the Running User of a Report
In multi-currency organizations, reports have an option to set a currency. This value is automatically set to the currency specified for the user who creates and saves a report. There is no “dynamic” option available in the report builder that allows a report to use the currency specified for the running user. But what if you want to create one report that serves users in various currencies? Wouldn’t it be nice to set up a single dashboard and have it work for any user no matter which currency they operate in?
I set out to solve this problem. The documentation states “In reports, the primary currency reflects either the default corporate currency or the currency selected for the record. The secondary currency reflects the personal default currency of the user running the report, or the currency specified in the report criteria.“
Since that last statement is either/or, I thought “what if I remove the currency specified on the report?” I dove into the XML metadata of the report, removed the <currency> property, deployed the change back into my sandbox, and found that the report started automatically toggling the currency to match the running user.
This holds true for summary values shown in the currency field as well as all values shown in the corresponding “(converted)” field. When using these reports as the source for dashboard components, the currency fields continue to be dynamic as long as the dashboard is set up to run as the logged-in user.
It seems this is officially supported in the metadata based on the documentation, but there isn’t a way to set this in the report builder. Vote for this idea to make this native functionality. Until then, you can follow these steps in order to edit the metadata of your report.
Create a manifest file
Create a manifest file that specifies the reports you want to edit.
- Copy the below text into a text editor such as Notepad.
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>REPORTFOLDERAPINAME/REPORTAPINAME</members> <name>Report</name> </types> <version>50.0</version> </Package>
2. If you’d like to edit multiple reports simultaneously, add an additional <members> line for each report.
3. Replace “REPORTFOLDERAPINAME” with the API name of the report folder. Replace “REPORTAPINAME” with the API name of the report you want to edit. Be sure to leave a forward slash (/) between those two API names.
- you can find the API name for a report folder by going to the “Rename” option for a report folder and copying the “Folder Unique Name”
- you can find the API name for a report by going to the “Properties” option for a report and copying the “Report Unique Name”
4. Save the file with the name “package.xml” (be sure to choose “All files” for the “Save as type” option when using Notepad)
Workbench Method for Editing Metadata
Use Metadata API to retrieve and deploy using Workbench
- Login to https://workbench.developerforce.com/ using your Production or Sandbox credentials
- Under “Migration” choose “Retrieve”
- Click “Choose File” and select the manifest file you created above
- Click “Next”, then click “Retrieve”
- Download the zip file by clicking the link
- Extract the contents of the .zip folder
- Navigate to the “reports” folder, then the folder you retrieved, then open the report definition file using a text editor
- Find the line that starts with “<currency>” (use Ctrl-F or Cmd-F to search). Remove that entire line including the line break so that there is no gap. Be careful not to adjust any other code
- Save the new version
- Navigate back up to the root folder where you will find the “unpackaged” folder as the only item
- Create a zip file of this “unpackaged” folder
- In workbench, under “Migration” choose “Deploy”
- Click “Choose File” and select the zip folder you created above
- Click “Next”
- for Sandbox environments, you can leave all the default settings
- for Production environments, set the following options:
- Rollback On Error = true
- Test Level = RunLocalTests
- Click “Deploy”
Command Line Interface (CLI) Method for Editing Metadata
If you are already set up with a command line interface (using a tool like Visual Studio Code) for managing Salesforce metadata, this is an easy task. Simply retrieve the metadata definition for the report(s) in question using the manifest file created above, remove the line that specifies the <currency> property from each xml file, save, then deploy the new version back to your org.
Getting set up with a CLI can be a bit tricky, but is well worth it if you intend to make adjustments to metadata on a regular basis. Follow one of these tutorials to install the necessary programs and extensions:
- Install Salesforce Extensions for VS Code
- Quick Start: Visual Studio Code for Salesforce Development project on Trailhead
- Authenticate to the desired org
- Right-click on the manifest file you created and choose “SFDX: Retrieve Source from Org”
- Then follow steps 8 and 9 from the section above to edit the metadata files and save them
- For Sandbox environments, use the normal deploy command by right-clicking the manifest file and choosing “SFDX: Deploy Source to Org”
- For Production environments, try the above command, then click on the “Terminal” tab, press the “up” arrow on your keyboard, append ” –testlevel RunLocalTests” to the deploy command, and press “Enter”
Note: If you perform this change in the metadata, then later edit the report via the report builder and click “save”, a static currency setting will again be specified. You will have to remove the <currency> property from the metadata again after editing a report in order for currencies to be displayed dynamically.
Evan Ponter View All
Evan Ponter is a Salesforce Admin Hero from Baltimore, MD who has been focusing on declarative development since 2012. His desire to keep an org simple, streamlined, and maintainable by future admins has led him to being an expert on the declarative features of the platform. A deep understanding of reports, the importance of proper data modeling, and the utilization of declarative automation tools have propelled Evan along a blossoming Salesforce journey where he solves complex problems using clever solutions that provide the ultimate flexibility. When he's not logged into Salesforce, Evan enjoys playing bass guitar in a local rock band.
Leave a Reply