The Transform element in Salesforce Flow enables you to map and convert source data into target data. This element is compatible with screen flows, auto-launched flows without triggers, and record-triggered flows.
Understanding how to use this element effectively can significantly improve your data management capabilities within Salesforce.
Key Features
- Data Mapping: Users can directly map fields from source data to target data, simplifying the data transformation process.
- Data Transformation: The element supports the application of formulas to modify data values, allowing for complex data manipulation.
- Collection Handling: It can process collections of data, enabling transformations at a granular level.
- Apex Class Integration: The Transform element can leverage Apex classes for intricate data structures and logic.
Core Components
Source Data: This is the initial data that you want to transform. It includes the flow resources available to the flow, and you can add multiple resources.
Target Data: This is the data after transformation. If the target data is a collection, you can opt for multiple values, but the source data must contain one or more collections. The target data structure can be defined using an Apex class, data type (either Apex defined or a record), or an object.
Formula: The formula expression is used to transform the data and must be compatible with the target field data type. It can set a fixed value for the target data field or reference up to two source collections nested within each other.
Business Scenario:
Use Transform Element to clone all the opportunities associated with an Account by clicking a button on the Account page layout.
Create a New Flow: Create a new Auto-launched Flow to handle opportunity cloning. The button on the Account page layout will trigger the Flow.
Get Records Element:
Next, we need to retrieve the opportunities related to the account. Use the “Get Records” Element to pull in all opportunities associated with the current account. To do this:
- Set up a Text Variable called “AccountId” to hold the current account’s Id.
- Configure the Get Records element to retrieve all opportunities where the “AccountId” matches the current account.
Also Read: Salesforce Winter’25 Release Features For Admins
Use the Transform Element:
Once you’ve retrieved your collection of opportunities, use the Transform Element to clone them.
Set the Source Data to the retrieved opportunities and create a new collection for the cloned records.
To complete the cloning process, map fields like AccountID, Name, Opportunity Name, and StageName between the source and target collections.
Customize the Opportunity Name
One of the cool features of the Transform Element is the ability to manipulate field values before cloning.
In our example, we’ll add the suffix “-Cloned” to the name of each cloned opportunity.
Use the Formula Editor within the Transform Element to append “-Cloned” to the original opportunity name.
Create the Records
After mapping the fields and customizing the opportunity names, the next step is to create the cloned opportunities. Use the Create Recordselement to insert the new opportunity records into the Salesforce org.
Once the Flow is built, save and activate it.
Add a Button to the Account Page Layout:
To add a button to the Account page layout that triggers this Flow:
- Navigate to Buttons, Links, and Actions under the Account object, and create a new button that directs to the Flow’s URL.
- Ensure the URL includes the current “AccountId” so the Flow can identify which account’s opportunities must be cloned.
FAQs
1. How does the Transform Element work in Salesforce Flow?
The Transform Element takes data inputs, applies logic or formulas, and returns modified data. It allows users to adjust field values, create calculations, or map data based on predefined conditions.
2. Can we use formulas within the Transform Element?
Yes, you can use formulas in the Transform Element. Formulas allow you to apply complex logic, perform calculations, or modify field values based on certain conditions.
3. What is the difference between the Transform Element and the Assignment Element?
The Transform Element uses formulas and logic to modify data, while the Assignment Element assigns values directly to variables. Both elements can change data, but the Transform Element provides more flexibility for applying transformations.
Conclusion:
The Transform Element in Salesforce Flow simplifies data mapping and modification, offering flexible features like formula-based adjustments and Apex class integration. It allows for efficient data handling, making tasks like cloning opportunities easier and improving Salesforce data management.