Currency Formatting and Exchange
  • 21 Aug 2023
  • 3 Minutes to read
  • Dark
    Light

Currency Formatting and Exchange

  • Dark
    Light

Article Summary

Overview

Another Localization tool is the Foreign Exchange Module that interacts between Decisions and a CurrencyLayer.com Account to provide currency exchange data for financial tasks.


Example

The following example details how to set up the ForeignExchange Module and use it to create a two Form process that converts a defined Currency Amount/Type into another Currency Type/Amount, based on CurrencyLayer values.

Pre-requisite
  • Install the ForeignExchange Module
For more information on installing Modules, see Installing Modules in Decisions.
  1. In the Studio, navigate to System > Settings.
  2. Locate and select Foreign Exchange Settings.
  3. Input the CurrencyLayer.com API Key corresponding to the used CurrencyLayer Account, then click SAVE.
  4. From a Designer Project, select CREATE FLOW, choose Flow, provide a Name, then click CREATE. 
  5. From the Flow Designer, attach a Show Form step from the FAVORITE STEPS category of the Toolbox tab.
  6. From the Properties tab of the Show Form step, select PICK OR CREATE FORM, then CREATE a new Form
  7. Design a Form using a Number Box, two Text Box components, a Button, and three Labels.
    Select each Text Box to navigate to their Properties; under BEHAVIOR, change Maximum Length to "3". Save and close the Form.
    This Form will serve as the input Form for both the amount of a currency, the original form of currency, and the desired converted currency type. Limiting the character length ensures that a user only types the required number of characters for a supported CurrencyLayer currency.  

    For a list of supported currencies, see CurrencyLayer Supported Currencies.

  8. Back in the Flow Designer, navigate to the input Form's Properties; set each INPUT to Ignore.

    Setting each Input to Ignore allows the user to enter their own value upon running the Form. 

  9. From Toolbox > INTEGRATION > FOREIGN EXCHANGE and attach a Do Conversion step to the Form step. On the newly added step, navigate to Properties > INPUTS and define each INPUT. 

    Map this step as follows: 
    • Map the Output from the Amount box on the Form to its respective Input.
    • Map the Original Currency box Output to From.
    • Map the Desired Currency box Output to To.

  10. Attach an additional Show Form step to the Do Conversion step; from the Properties tab of this step, select PICK OR CREATE FORM and CREATE a new Form. 

  11. Design a Form containing a single Text Box, a Number box, a Label, and a Button. Then, Save and close the Form. 

    This Form serves as a display for the converted amount. The Text Box displays the converted Currency Type, and the Number Box displays the converted numerical value. The Button serves as a Done Button.

  12. Back in the Flow Designer, attach the Done path to the End step.

  13. Navigate to the Display Form's Properties; map DoConversion1_Ouput to Converted Amount [Number Box] and DesiredCurrency to Currency [Text Box]

  14. Save the Flow, then if desired, close the Designer via X



Debug 

  1. From the Flow Designer, select the Debug link from the top action bar.
  2. Click START DEBUGGING. 
  3. When the Flow runs, upon reaching the Currency Input Form, input the numerical Amount, the original 3-character Support Currency type, and the Desired Currency type for conversion, then click the Convert Button. 
    Clicking Convert will make the Flow proceed to the Display Form, displaying the Converted Amount with the new Currency type. 


Get Conversion Rate

In addition to the Do Conversion step, the Foreign Exchange Module offers the ability to use a step to source the current exchange rate for two currencies. This value can be, in turn, mapped to things such as the exchange rate Dashboards, or may simply be used as data within a Flow.

To use the Get Conversion Rate step:
  1. From the Flow Designer, navigate to the Toolbox tab and navigate to INTEGRATION > FOREIGN EXCHANGE. 
  2. Attach a Get Conversion Rate step to the Start and End steps. 
  3. Navigate to the Get Conversion Rate step's Properties tab by selecting it. 
  4. Map the desired starting 3 character supported currency to the From Input, and the desired converted currency to the To Input. 
  5. Save the Flow, then if desired close via X
  6. Debug the Flow by selecting the Debug link from the top action bar, then clicking START DEBUGGING. 
  7. Once the Flow runs, navigate to Get Conversion Rate 1 > Execution 1 > View Input/Output Data
    The resulting data will display the Conversion rate from one unit of the Currency Type to its equivalent amount in the To Currency Type.



Was this article helpful?

What's Next