Transforming Data in Flows

by Zuber Rangreaz

Hello friends, today we are going to discuss Transforming Data in Flows. Data transformation is converting data from one format or structure into another to make it more appropriate and valuable for application feeds. In this blog post, we’ll explore how to effectively transform data within Salesforce flows.

Previously, when we built a flow that had HTTP Callout we included the Loop element and the Assignment element for response data conversion. Now we can do it all with the Transform Data element

Also, check this: Email Quick Action in LWC

Key Highlights :

  1. The Transform element appears under the Logic section of the toolbox and is available in all flow types. It allows you to transform source data into target data. You can select resources such as outputs from actions, record variables, and Apex-defined variables as your source data.
  2. Mapping the Data: After selecting the source and target data, you’ll need to map the fields. Click on the circled bullet icons next to the fields to map them. You can map fields from the source data to fields in the target data.
  3. Aggregate Calculations The Transform element also supports aggregate calculations, making it easier than using Loop and Assignment elements. For example, you can count records or sum field values easily. Choose a collection as the source data and a single record variable as the target data.
  4. Output of the Transform Element: The Transform element stores the mapped data in a new record variable or Apex-defined variable (single or collection). Note that you cannot choose an existing variable as the output; it always creates a new one.

Code :

Step 1:  We set up an OpenWeatherMap account. You can log in via Gmail. After creating an account go to your profile name (Username) and click My API Keys. Set and copy the API key for further processing.

Step 2 : Create a Named Credential(New Legacy) and fill out the page with the callout endpoint’s URL and authentication parameters.(

Step 3 : Create a Record-Triggered Flow on Account object with given details in the below image. Click Include a Run Asynchronously path to access an external system link to create a separate path so we can call HTTP Callout after the original transaction for the triggering record is successfully committed.

Step 4: Under the Run Asynchronously node, select Action. On the bottom click the Create HTTP Callout link.

Configure the external service that connects Salesforce to the HTTP-based API.

  1. Enter a Name for the external service.
  2. Select the named credential that we already created in step 2.

Click next for setup Configure Invocable Action details. Check the details in the below image

Step 5: Click next to set up the response body, you can select Connect for Schema and add the API key and City name, you will get JSON body, click save.

Step 6 : Now we will define API key variable so we can assign this to Http action paramater.

For City Name we add Billing City name.

Step 7 : Now we add Transform data element so can map JSON response data(source) to Account record data (target data). In source Data, select output of Get weather info.

Step 8: By selecting fields map the fields in the Transform element.

Here I used the formula for temperature because the value is in Kalvin so I made this in celsius.

So much stuff but now only 1 step remaining 😅

Step 9: Here we assign the record ID to Account record so we can update it

Final Flow :

Output :

Reference :

  1. Transform Data in a Flow
What’s your Reaction?

You may also like

Leave a Comment