Join Collections with the Transform Element

You now have the ability to merge multiple collections of different types into a single collection using the highly effective Transform element If you need to integrate data from two distinct collections—gathering specific information from one and different details from another—and combine them into a new, unified collection, this process is now completely possible! The Transform element makes it easier than ever to consolidate and manipulate data from diverse sources into a cohesive format.

What transform Element is in Salesforce?

In Salesforce Flow, the Transform Element is a useful tool for manipulating and reshaping data. One of its key features is its ability to map data from a source collection to a target collection, helping you structure and process the data for further use. However, when working with multiple collections (such as Account and Contact records), you may encounter difficulties in trying to "join" or merge them into a single collection. This is where the Transform Element becomes particularly useful.

Use Case: Joining Account and Contact Records

Let's say you have two collections:

  • AccountCollection: A list of Account records.
  • ContactCollection: A list of Contact records.

The goal is to merge the data from both collections into a new collection, where each entry in the collection contains fields from both Account and Contact records.

Wrapper Class:

A wrapper class in Salesforce is a custom class that allows you to group multiple pieces of data (often from different objects) into a single object. It's particularly useful when you need to combine data from different sources (e.g., Account and Contact records) into one unified structure, allowing for easier handling and manipulation.

  • Create a wrapper Class to store the result of combined fields from the Transform Element.
  • As shown in the figure.

Wrapper Class

Follow the steps below:

1) Open the Flow from the setup and Create a new Flow.

2) Create 2 Collection Variables for storing the fetched Account and Contact.

Collection Variables

Record Collection Variables

3) Add Get Record Element to fetch the Account and apply the filter condition (optional).

4) Repeat Step 2 for Contact and apply filters accordingly.

Contact Filters

Contact Filters 2

5) Add the Transform Element.

Flow Chart Filters

6) Click add Data source and for resource select account variable.

Data Source

7) Add another data source for the contact variable.

8) Now add the target data source Select Data Type Apex-Defined.

9) Check the checkbox and enter the name of your wrapper class hit Create.

hit Create

10) Now Map account(Source Data) with transformJoin(Target Data).

Source Data

11) Repeat the same with contact(Source Data).

12) Select Id from the Left Source Collection and AccountId from the Right Source Collection.

Source Collection

Here Id and AccountId will be used as a key to perform inner join on the data.

13) Select Field and add the following 4 fields:

account: Name, Type

contact: FirstName, LastName and click set fields.

14) Click Select Joined Field Mappings. Map the fields as shown below and click set mappings.

Field Mapping

debug

15) Save the flow and hit debug, it will give the following target data.

Key points to remember:

This feature might not be available in all the Org. But you can create a new Pre-release Spring 25 org to test this from the link below:

https://www.salesforce.com/form/signup/prerelease-spring25/

Conclusion

The Transform Element in Salesforce Flow is a powerful tool for combining data from different sources into a single structure. While it simplifies field mapping, it has limitations, such as not supporting direct joins of multiple collections or complex join operations. However, these limitations can be overcome by using wrapper classes, loops, and custom logic. With careful planning, the Transform Element can enhance your flows, optimize data processing, and support advanced automation—offering flexible and efficient solutions with minimal coding.

For additional questions on Experience please reach out to support@astreait.com