Loading...

Salesforce introduced the transform element in their winter ‘24 release. This feature simplifies data processing in flows by eliminating the need for loops and assignment elements.

With the Transform Element, you can seamlessly map source data to target data, making your flows more efficient and easier to maintain. Transform element is available for screen flows, auto-launched flows with no triggers, and record-triggered flows.

In this blog, we will walk you through the steps to use the Transform Element in salesforce flow.

Key features

  • Enables seamless mapping between source data and target data which simplifies the data transformation process.
  • Handle data collections and transform each item individually. 
  • Enables dynamic field mapping using formulas.
  • Supports aggregate calculations like sum and count.

Transform Element Component

  • Source Data: Data to transform which are available to the flow.
  • Target Data: Data after transformation. Target data could either be a single record or a collection of records. You define the target structure using an Apex class, a data type (Apex-defined or Record), or an object.
  • Formulas: Set a fixed value for the target data field or Reference up to two source collections that are nested within one another.

Business scenarios 

Case 1: Clone records, such as Accounts, Opportunities, etc

Create a Screen Flow to clone Account records selected by the user on the screen.

Step 1: Go to setup and create a Screen Flow.

Step 2: Add a Get Records element to the flow to retrieve all Account records.


Step 3: After retrieving all Account records, add a Screen element to allow the user to select the Accounts for cloning.

To display the Accounts on the screen, drag and drop a Data Table component onto the screen. And configure data sources, rows, and columns.

Set the Get Account Records collection as the source collection to populate the Data Table.

Set the Rows option to ‘Multiple’. 

Configure Columns by adding Name and Industry fields.

Step 4:  After selecting the Accounts for cloning, use the Transform element to map and prepare the Account data for cloning

 Add a resource to the source data.

After selecting the source data, choose selected rows to map the collection for cloning multiple records. If you want to clone only a single record, select firstSelectedRow to map the data to the target.

To map selected rows to the target data, add a Resource and set the data type to Record. Ensure to check the ‘Allow multiple values’ checkbox. Then, select the target object as Account.

After creating the target collection variable time to map the source data with the target data

To indicate that a record has been cloned by this flow, you can append ‘Cloned’ to the name of the record (e.g., ‘Edge Communications Cloned’). This can be achieved by using a formula in the Name field of the target data while mapping.

Add formula as per the business requirement

Step 5:  After completing the mapping between the source data and the target data, add the Create Records element.

Enable Multiple toggle to specify the creation of multiple records. Then, select the Map Accounts collection to create the cloned records.



Step 7: Save and activate the flow. 

Step 8: Add flow to the Home Page

  1. Go to the gear icon and select the edit page 
  2. Search for the Flow component
  3. Drag and drop the flow onto the desired section 
  4. Select the Flow 
  5. Save the page

Test the screen flow :

Select the records you want to clone from the displayed list.

After selecting the records click on the next button for cloning the records.


To check the selected accounts are cloned successfully.

Go to the account page and select All Accounts list view. You see the records with ‘Cloned’ appended to their name.

Result:  All selected accounts have been cloned.
Here is the Demo.

https://youtu.be/4awc1Qqg7fg

Case 2: Used for Aggregate Calculations

Display the total sum of the ‘Amount’ field and the count of all related Opportunities where the Stage is ‘Closed Won’ on the account record.

Prerequisite: 

Create two custom fields on the Account object.

  1. Total Closed Won Amount field to store the sum of total opportunities amount where the stage name is ‘Closed Won’. The data type will be currency.
  2. Count of Closed Won Deals field to store the total count of opportunities related to the account where the stage name is ‘Closed Won’. The data type will be a number.

Step 1: Go to the flow and select Record-Triggered Flow 

  1. Select opportunity object 
  2. Select A record is created or updated when to trigger the flow 
  3. Set the entry conditions mentioned in the image 

Step 2: Add a Get Records element to retrieve all related Closed Won Opportunities.

 Set the following conditions:

  1. Account ID equals the Record Account ID.
  2. StageName equals ‘Closed Won‘.

Step 3: Add a Transform element to map the source data with the target data 

A. Add record collection to the source data.

B. Configure target data 

C. Map source data with target data 

To calculate the total opportunities amount, Map the source collection to the Total Closed Won Amount field of the target data source.

To calculate the count of the closed won opportunities related to the account, Map the source data to the Count of Closed Won Deals field of the target data. 


Step 4: After mapping the data, add an Update Records element to update the Account records.

Set Total Closed Won Amount and Count of Closed Won Deals fields 


Step 5: Save and Activate the flow 

Test the record-triggered flow. 

Select an Account that has related Opportunities.s


Go to the opportunity record and change the stage to closed won.


After updating the opportunity, go to the related account and check whether the fields are populated with the correct values.

Result: Both the Total Closed Won Amount and Count of Closed Won Deals fields are populated with the correct value.

Now add one more opportunity with closed won and associated with the same account. 

After saving a new opportunity go back to the related account and check the fields are updated correctly.


Result: Both The total Closed Won Amount and Count of Closed Won Deals fields populated with the correct value.

Here is the Demo.

https://www.youtube.com/watch?v=jEYbV5R62K4

Conclusion

The Transform Element in Salesforce Flow simplifies data mapping and modification by allowing the conversion of multiple variables into a single or collection variable. It supports features like formula-based adjustments, Apex class integration, and aggregate calculations. 

While tasks like cloning accounts or data handling can be achieved using Loop and Assignment elements, the Transform element streamlines the configuration process, making it faster and more efficient.

 Stay tuned for more informative blogs! Click here!


Salesforce Experts

Related Articles

Sticky notes aren’t just for your desk anymore! In this tutorial, we’ll create a Lightning Web Component (LWC) in Salesforce that allows you to pin notes on your app page or record page. With a clean, interactive UI, these digital sticky notes ensure you never forget important tasks or details. What Will You Learn? By […]

Read More
How to Create Dynamic, Animated Charts in Salesforce LWC using Chart.js

Bring Salesforce data to life with dynamic charts inside Lightning pages! While Salesforce dashboards are powerful, sometimes business users want visual insights without leaving their current page. That’s where Chart.js with Lightning Web Components (LWC) becomes a game-changer. In this step-by-step guide, you’ll learn how to: Upload Chart.js as a static resource in Salesforce. Build […]

Read More
How to Encrypt and Decrypt Data in Salesforce Using Apex Crypto Class

Data security is more important than ever. Whether you’re storing customer information, sensitive business data, or private communication, ensuring that your data stays safe is critical. Salesforce provides built-in tools to help with this, and one of the most powerful yet easy-to-use approaches is encryption and decryption using the Apex Crypto class. In this blog, […]

Read More
Benefits & Step-by-Step Setup Guide for Salesforce Code Analyzer

When building on the Salesforce platform, code quality and security are non-negotiable, especially before submitting your app for a Salesforce Security Review. Catching bugs and vulnerabilities early not only saves time but also ensures compliance with Salesforce’s best practices. That’s where the Salesforce Code Analyzer comes in. This open-source tool scans your Apex classes, triggers, […]

Read More
A Step-by-Step Guide to Integrate Zoho CRM with Salesforce (Without Coding)

Managing data across multiple CRMs can be a real challenge for businesses that want a single source of truth. If your teams use Zoho CRM but want to move or sync all records seamlessly into Salesforce, you don’t need to write a single line of code. Thanks to MultiSync Made Easy, the integration process is […]

Read More
How to Integrate Salesforce with Copilot

Integrating Salesforce with Copilot is becoming an essential step for organizations aiming to streamline workflows, automate client data management, and unlock the power of AI-driven CRM. By connecting these two platforms, businesses can centralize customer information, reduce manual tasks, and accelerate growth. This guide walks you through the Salesforce–Copilot integration process with clear steps, Apex […]

Read More