Let’s say you need to determine the number of unique accounts across a series of opportunities.
The old school method of doing this in a flow is using nested loops. Nested means you loop within a loop. You do this because you don’t want to have a Get operation instead of a loop.
The steps in the flow look like
- Get the specific opportunities
- Get all accounts (hopefully with some criteria to avoid getting literally all accounts)
- Loop through all opportunities
- Loop through all accounts
- Have a decision to determine whether current account is for the current opportunity and not already in a collection called UniqueAccounts
- If the above is true, add the current account to UniqueAccounts
Enter the transform element. With this new-ish functionality, you can skip the nested loops and map directly from opportunities to accounts.
The resulting steps in the flows are
- Get the specific opportunities
- Transform from opportunities to accounts, matching on AccountId
- Loop through the resulting accounts
- Have a decision to determine whether the current account is not already in a collection called UniqueAccounts
- If the above is true, add the current account to UniqueAccounts
See the benefit?
The takeaway
Using a transform element saves time, reduces technical complexity and is also fun to use.
Category:
Salesforce