Configuring a Salesforce Flow To Automatically Populate Historic Exchange Rate Fields on Your Source Records

Warning:

These instructions are intended for users who are experienced at creating Salesforce flows and processes. Refer to the Salesforce Help if you require more information.

To automatically populate historic exchange rate fields on your source records you must set up a Salesforce flow to retrieve and populate the rates, then create a process using Salesforce's Process Builder to trigger the flow once a source record is ready to receive this information.

Before building your flow and process, you must create the following fields on the source object. You can either add them by enabling the Historic FX Rates - Source Object Setup feature in Feature Console (see Enabling Historic FX Rates - Source Object Setup), or you can add them manually.

Field Label

Field Name Type
Document Rate ffrrDocumentCurrencyRate__c A number field with 9 dp
Dual Currency ffrrDualCurrency__c A text field of 3 or more characters
Dual Rate ffrrDualCurrencyRate__c A number field with 9 dp
Home Currency ffrrHomeCurrency__c A text field of 3 or more characters

Once these fields are added to your source object you must map them to the currency fields in your source object's settings record. This allows Revenue Management to use the historic exchange rates when calculating amounts to recognize.

For this example flow we use the exchange rates that are configured in the exchange rate groups in Foundations. You must make sure that exchange rates are set up for the type and relationship that you require, i.e. your document currency must match the default currency in your exchange rate group.

All the illustrations for this example are shown as thumbnails. To expand an image, click it. To close an expanded image, click it again.

Here is an outline of the flow you will be building. In this example, Billing Contract Line Item is used as the source record.

Diagram of Process Flow to Auto Populate Historic FX Fields

The flow type is an autolaunched flow which means it can be triggered manually or through the Process Builder. This example flow will be called with an input variable called VRecordId which will contain the record Id of the source record that triggered the flow.

Here is an outline of the process:

Diagram of Process that Triggers Flow to Auto Populate Historic FX Fields

The process is responsible for triggering the flow when source records are created or updated. There is a boolean that if true will trigger the flow with the given recordId of the record that triggered the process. In this example the “Rates blank” boolean is when Document Rate and Dual Rate have no value.

Note that:

  • Document rate (also known as home rate) is the document currency relative to the home currency.
  • Dual rate is the dual currency relative to the home currency.

Creating The Flow

Step 1: Create an autolaunched Flow

From Setup, navigate to Flows. Create a new flow of type Autolaunched Flow (No Trigger).

Step 2: Create VRecordId input variable

In the Flow Builder user interface, go to the Toolbox section on the left-hand side of the page and click on Manager then click the New Resource button. On the New Resource window, set the Resource Type to Variable, then set the following:

API Name: VRecordId
Data Type: Text
Available for input: True

Screenshot of Creating a Variable in the Flow UI

Step 3: Create a Get Records Element for Billing Contract Line Item

This step will load the contract line item data into the flow based on the input variable “VRecordId” created in the previous step.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Billing Contract Line Items
API Name: Get_Billing_Contract_Line_Items
Object: Billing Contract Line Item

Set the filter condition:

Id equals VRecordId

Sort Order: Not Sorted
How Many Records to Store: Only the first record
How to Store Record Data: Automatically store all fields

Screenshot of Creating a Get Records Element for Billing Contract Line Item

Step 4: Create a Get Records Element for Billing Contract

This step will load the associated billing contract data into the flow.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Billing Contract
API Name: Get_Billing_Contract
Object: Billing Contract

Set the filter condition:

Id Equals {!Get_Billing_Contract_Line_Items.ffbc__Contract__c}

Sort Order: Not Sorted
How Many Records to Store: Only the first record
How to Store Record Data: Automatically store all fields

Screenshot of Creating a Get Records Element for Billing Contract

Step 5: Create a Get Records Element for Accounting Company

This step will load the linked accounting company of the contract into the flow.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Accounting Company
API Name: Get_Accounting_Company
Object: Accounting Company

Set the filter condition:

ERP_Company__c Equals {!Get_Billing_Contract.ffbc__Company__c}

Note:

ERP_Company__c is a lookup to a Foundations (FDN) company from the Accounting company (FFA). Create the field manually if it does not already exist in your org. You must populate this field for each Accounting company.

Sort Order: Not Sorted
How Many Records to Store: Only the first record
How to Store Record Data: Automatically store all fields

Screenshot of Creating a Get Records Element for Accounting Company

Step 6: Create a Get Records Element for Home Currency

This step loads the related home accounting currency into the flow.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Home Currency
API Name: Get_Home_Currency
Object: Accounting Currency

Set the filter conditions:

c2g__OwnerCompany__c Equals {!Get_Accounting_Company.Id}

AND c2g__Home__c Equals true

Sort Order: Not Sorted
How Many Records to Store: Only the first record
How to Store Record Data: Automatically store all fields

Screenshot of Creating a Get Records Element for Home Currency

Step 7: Create a Get Records Element for Dual Currency

This step loads the related dual accounting currency into the flow.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Dual Currency
API Name: Get_Dual_Currency
Object: Accounting Currency

Set the filter conditions:

c2g__OwnerCompany__c Equals {!Get_Accounting_Company.Id}

AND c2g__Dual__c Equals true

Sort Order: Not Sorted
How Many Records to Store: Only the first record
How to Store Record Data: Automatically store all fields

Screenshot of Creating a Get Records Element for Dual Currency

Step 8: Create VHomeRate Variable

Create a variable called VHomeRate. This will hold the value found on the filtered Historic Exchange Rates - Rate field.

API Name: VHomeRate
Data Type: Number
Decimal Places: 9

Screenshot of Creating a Variable in the Flow UI

Step 9: Get Home Rate

This step is responsible for assigning the variable VHomeRate. It reads in a list of Exchange Rate History objects and is filtered down to a single exchange rate which is the latest rate for the billing contract line item's start date.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Home Rate
API Name: Get_Home_Rate
Object: Exchange Rate History

Set the filter conditions:

fferpcore__Group__c Equals {!Get_Accounting_Company.c2g__ExchangeRateGroup__c}

fferpcore__RateType__c Equals Commercial

fferpcore__RateCurrency__c Equals {!Get_Billing_Contract_Line_Items.CurrencyIsoCode}

fferpcore__RelativeCurrency__c Equals {!Get_Home_Currency.Name}

fferpcore__StartDate__c Less than or equal to {!Get_Billing_Contract_Line_Items.ffbc__StartDate__c}

Screenshot1 of Creating a Get Records Element for Home Rate

Sort in Descending order by fferpcore__StartDate__c in order to find the most recent exchange rate first.

Screenshot2 of Creating a Get Records Element for Home Rate

Set the remaining fields as follows:

How Many Records to Store: Only the first record
How to Store Record Data: Choose fields and assign variables (advanced)
Where to Store Field Values: In separate variables
Field: fferpcore__Rate__c
Variable: VHomeRate
When no records are returned, set specified variables to null: True

Screenshot3 of Creating a Get Records Element for Home Rate

The outcome is that the fferpcore__Rate__c from the Historic Exchange Rate is assigned to the variable VHomeRate.

Step 10: Create VDualRate Variable

Create a variable called VDualRate. This will hold the value found on the filtered Historic Exchange Rates - Rate field.

API Name: VDualRate
Data Type: Number
Decimal Places: 9

Screenshot of Creating a Variable in the Flow UI

Step 11: Get Dual Rate

This step is responsible for assigning the variable VDualRate. It reads in a list of Exchange Rate History objects and is filtered down to a single exchange rate which is the latest rate for the billing contract line items start date.

Add a Get Records element to the flow and complete the New Get Records window as follows:

Label: Get Dual Rate
API Name: Get_Dual_Rate
Object: Exchange Rate History

Set the filter conditions:

fferpcore__Group__c Equals {!Get_Accounting_Company.c2g__ExchangeRateGroup__c}

fferpcore__RateType__c Equals Commercial

fferpcore__RateCurrency__c Equals {!Get_Dual_Currency.Name}

fferpcore__RelativeCurrency__c Equals {!Get_Home_Currency.Name}

fferpcore__StartDate__c Less than or equal to {!Get_Billing_Contract_Line_Items.ffbc__StartDate__c}

Screenshot1 of Creating a Get Records Element for Dual Rate

Sort in Descending order by fferpcore__StartDate__c in order to find the most recent exchange rate first.

Screenshot2 of Creating a Get Records Element for Dual Rate

Set the remaining fields as follows:

How Many Records to Store: Only the first record
How to Store Record Data: Choose fields and assign variables (advanced)
Where to Store Field Values: In separate variables
Field: fferpcore__Rate__c
Variable: VDualRate
When no records are returned, set specified variables to null: True

Screenshot3 of Creating a Get Records Element for Dual Rate

The outcome is that the fferpcore__Rate__c from the Historic Exchange Rate is assigned to the variable VDualRate.

Step 12: Create FHomeRate and FDualRate formulas

Create the final formulas that are used to populate the contract line item at the end of the flow.

API Name: FHomeRate
Data Type: Number
Decimal Places: 9
Formula: IF(ISNULL({!VHomeRate}),1,{!VHomeRate})

Screenshot of Creating a Formula in the Flow UI

API Name: FDualRate
Data Type: Number
Decimal Places: 9
Formula: {!FHomeRate} * IF(ISNULL({!VDualRate}),1,{!VDualRate})

Screenshot of Creating a Formula in the Flow UI

Step 13: Create an Update Records Element for Billing Contract Line Item

This is the final step responsible for updating the billing contract line item. It is an update step type.

Add an Update Records element to the flow and complete the New Update Records window as follows:

Label: Update Contract Line Item ER
API Name: Update_Contract_Line_Item_ER
How to Find Records to Update and Set Their Values: Specify conditions to identify records, and set fields individually
Object: Billing Contract Line Item

Set the filter condition:

Id Equals {!Get_Billing_Contract_Line_Items.Id}

Screenshot1 of Creating an Update Records Element for Billing Contract Line Item

Make the following assignments in the Set Field Values for the Billing Contract Line Item Records section:

ffrrDualCurrency__c = {!Get_Dual_Currency.Name}

ffrrDualCurrencyRate__c = {!FDualRate}

ffrrHomeCurrency__c = {!Get_Home_Currency.Name}

ffrrDocumentCurrencyRate__c = {!FHomeRate}

Screenshot2 of Creating an Update Records Element for Billing Contract Line Item

Note:

The field names in your org might differ from the field names shown in the screenshot above.

Step 14: Save and Activate Your Flow

Save your flow then click Activate.

Creating the Process

Step 1: Create a Process That is Triggered When a Record Changes

From Setup, navigate to Process Builder and click the New button. Set the process to start when a record changes.

Screenshot of Creating a New Process in Process Builder

Click to Add Object and set the Object to Billing Contract Line Item - this is the source object that needs to update its exchange rates. Set the process to start when a record is created or edited.

Screenshot of Adding an Object to Process in Process Builder

Step 2: Add Logic to Determine if Populating Exchange Rates Needs to Happen

Click to Add Criteria and enter a name, then set:

Criteria for Executing Actions: Conditions are met

Set Conditions:

ffbc__ContractLineItem__c.ffrrDocumentRate__c Is Null Equals True

ffbc__ContractLineItem__c.ffrrDualRate__c Is Null Equals True

Conditions: Any of the conditions are met (OR)

Screenshot of Adding Criteria to Process in Process Builder

Step 3: Call the Flow to Populate Exchange Rate Fields

Click to Add Action and set Action Type to Flows. Enter an action name then pick your flow.

Set the flow variable VRecordId to a field reference of: ContractLineItem__c.Id

This will give the context to the flow builder on which billing contract line item triggered the process.

Screenshot of Adding an Action to Process in Process Builder

Step 4: Save and Activate Your Process

Save your process then click Activate.