The Salesforce Winter ’24 release introduces a great new addition to the Flow Builder toolbox: the Transform element. In this article, we examine the new functionality in detail.
The Transform element does not introduce anything that was not possible before, but it does make mapping fields from a source record to a target record much more user-friendly, faster and more insightful. In many cases, you could replace an entire loop with one single Transform element.
Let's start with the most basic way to use it. I will use a bit of FieldBuddy to illustrate how it works.
In FieldBuddy, the Work Order Item object is used as a template for parts, activities, and other expenses that can be linked to a Work Order.
Work Order Line Items are the parts, activities and other costs associated with a Work Order that are created based on such templates.
These two different objects have a number of fields in common, which must be filled with the value from the matching field of the template record when creating Work Order Line Items.
Before the introduction of the Transform element, it would look like this:
Each field needs to be mapped by manually selecting the right variable and field. Often you need to hover over the chosen field to verify that it is correctly mapped.
Using the Transform element you can create this mapping much easier and quicker. Also this interface shows what is mapped to what more clearly.
Output variable
The Transform element auto-creates the output record variable - in this case a Work Order Line Item.
The name and API name of the variable are the same as the name and API name of the Transform element itself. So if the name of the output variable is not quite as you want it, you adjust the (API) name of the element.
A whole collection at once
Net zo gemakkelijk als één record gebruiken als brondata, kun je ook een hele Record Collection ineens als input gebruiken. De output variabele moet dan ook een Record Collection zijn. In veel gevallen kan het gebruik van een Transform element dus ook het gebruik van een loop overbodig maken.
Assignment using a formula
Apart from using an exact value from the source record, you can also transform this value using a formula.
For example you could calculate a price including tax using the source record's price excluding tax and the tax rate.
You can create a formula for this directly within the Transform element. So that too is a more streamlined experience than creating a separate formula and then using it in an Assignment.
You can also use values from other variables, formulas and constants in the flow in such a formula. However, for this you must first map a field from the selected source record to this target field. After doing so, you can turn this into a formula.
Then while editing the formula, you can also access all other variables, formulas and constants in the flow. And if necessary, you can remove any reference to a value from the 'default' source record – in this case a Work Order Item.
After saving, refreshing and re-opening the Transform element you can also view the other source variables used in any formula used in the mapping.
This is therefore somewhat cumbersome and could be a point for improving the functionality.
To conclude, a very direct example of how a Transform element, used with a Record Collection as input and Output, can replace a loop