This article explores using a Scheduled Workflow and Markup features in Commander to automatically set an exchange rate on a Commander Cost Model.

This example uses the Exchange Rate API, available here, and is backed by exchange data from the European Central Bank. Currencies available for conversion depend on the data available from this API. 

The end result of configuring this solution is that self-service portal users will see all costs in the foreign currency you set. Please note that the Admin UI will only see a subset of costs in the foreign currency.


Create the Commander REST API Credential

It is recommended to create a superuser account in Commander that is used only for API actions such as the workflow in this article so you can easily identify actions taken by workflows or other automated systems.

If you have already created a credential for use with the Commander REST API you can skip this section and use that credential instead.

  1. In Commander, select Configuration > Credentials.
  2. Click Add.
  3. In the Add Credentialsdialog:
    1. Select Username/Password for the Credentials Type.
    2. Enter Commander REST API for the Name.
    3. Enter the required username (for example "apiuser") and password.
    4. For Category, select Guest OS Credentials.
    5. Click OK.

Create the Scheduled Workflow

  1. In Commander, select Configuration > Command Workflows.
  2. Click Add.
  3. In the Command Workflow Configuration dialog:
    1. Enter Commander Forex Sync for the Name.
    2. Select No inventory Target as the Target Type. Click Next.
    3. Add an Execute Embedded Script step.
    4. Enter Sync Forex for the Name.
    5. Select the Commander REST API credential.
    6. Enter powershell.exe for the Executable.
    7. Copy and paste the contents of the commander_forex_sync.ps1 file into the Script Contents.
    8. Edit the Script Contents and set the $baseCurrency to the 3-digit currency code for the currency your billing data is received in.
    9. Set the $convertToCurrency to the 3-digit currency code for the currency you want to convert your billing data to.
    10. Set the $targetCostModel to the name of the Commander Cost Model related to the costs you wish to convert.
    11. Click Next and save the workflow.
  4. On the Command Workflow list, select the Commander Forex Sync workflow and select Schedule > Schedule at the bottom.
  5. Set the Frequency to Daily and select a Time. Click Next and save the schedule.

Configure the displayed Currency Symbol

  1. In Commander, select Configuration > Costs. Select Cost Configuration.
  2. Select the currency symbol you want to display from the Currency Symbol dropdown.
  3. Click Save Settings to save your changes.

Once the Scheduled Workflow runs the script will retrieve the currency exchange rate between your base currency and the convert-to currency and save it to the Cost Model you chose. 

The exchange rate will be stored as the Markup of the selected Cost Model and will apply to all costs seen by users in the Commander User Portal.

Combined with the selected Currency Symbol the Commander User Portal users will see prices in their local currency value and with their local currency symbol.