Using Flow To Split, Merge & Amend Opportunities
This is a technical article focused on how to build a single-screen flow step-by-step in Salesforce that allows end users to split, merge, and expand Opportunities.
In this use case, the build is specific to Renewal Opportunities that only use Opportunity Products and a custom Subscription Object. No Quotes or Quote Line items are used in this build, but adding functionality for these would be possible. The Subscription Object here is a record linked to a specific Account, updated by an integration, and carried from Opportunity to Opportunity.
Most use cases will not utilize this kind of object, but they have been for this one. Below is a breakdown of the technical build that makes up this flow.
What Is Salesforce Flow?
Salesforce Flow is a powerful automation tool that allows admins and RevOps teams to build complex business logic without writing code. Whether it’s guiding users through a multi-step form (Screen Flow) or automating behind-the-scenes processes (Record-Triggered Flow), Flow helps streamline operations, reduce manual tasks, and ensure consistency across Salesforce. It’s a core tool for customizing your org in a scalable and maintainable way.
Why Automate Opportunity Splits, Merges, and Amendments with Salesforce Flow?
In B2B sales environments - especially in SaaS and tech - Salesforce Opportunities often represent complex, evolving deal structures rather than linear sales cycles. As deals progress, it's common for them to be split across different product lines, merged into consolidated agreements, or amended to reflect changing customer needs. Manually managing these updates is not only time-consuming but also introduces risk for errors and inconsistent data.
Salesforce Flow provides a scalable way to automate these processes, ensuring clean, reliable data while saving valuable time for sales and RevOps teams. It enables your CRM to reflect real-world sales complexity without compromising forecasting, reporting, or deal velocity.
Here are just a few scenarios that we've seen here at Candybox where automating Opportunity management with Flow makes a measurable impact:
- Splitting Opportunities across buying centers: A B2B sales team selling into large enterprises needed to break a single Opportunity into multiple deals, each aligned to a different internal business unit or buying center. Automating this ensured clearer ownership, better pipeline visibility, and more accurate revenue attribution.
- Merging deals for centralized procurement: Conversely, some customers with distributed regional offices wanted to consolidate multiple Opportunities into a single centralized deal to streamline procurement. Automating this merge process eliminated duplicate work and simplified billing alignment.
- Automating expansion Opportunities: In SaaS, expansion is a core motion. Manually creating new Opportunities for upsells or add-ons to an existing subscription can slow things down. With Flow, teams can trigger expansion Opportunities from renewal records or usage signals, which speeds up GTM motions and reduces errors.
- Handling product bundling or deal packaging: Some companies offer modular products or flexible bundles. Automating the process of creating sub-Opportunities or bundled parent deals using Flow can ensure that SKUs, pricing, and quoting stay accurate across systems.
- Amending Opportunities after contract changes: If a customer renegotiates contract terms mid-cycle - such as increasing seat count or changing product tiers - a Flow can auto-adjust the Opportunity and notify the right teams to take action.
By automating these scenarios, you not only reduce friction in your revenue processes but also empower your team to scale operations with precision and confidence.
How To Build Your Flow: Step-By-Step Guide
Launching the Flow & Initial Decision Branching
The flow is designed to be launched from the Opportunity level (e.g. via a page component or custom button), with the first element being a screen allowing end users to select one of three actions to perform. Selection of one of these three options is required to continue from this screen.

Following the selection screen is a decision path that will evaluate whether the user has decided to perform a split, merge, or amendment (expansion). Depending on the selection made, a specific split, merge, or amend path is followed in this decision element.

Splitting Opportunities

The Split functionality of this flow allows end users to separate an Opportunity by selecting its related Opportunity Products to split into one or many separate Opportunities. With Opportunity Products serving a central role in this functionality, the first section of the Split path checks if the current Opportunity has products by getting any related Opportunity Products, assigning a count of the products found, and then trigger an error message to display to the end user if the product count is 1 or less.
If the number of products is greater than 1, end users are presented with a table of Opportunity Products to select.
One thing to note is that end users are required to leave one product unselected in this table. This unselected product is the Opportunity product that will remain on the original Opportunity. This avoids the creation of Opportunities without any related products. After product selection, users then select how they would like to split the Opportunity products, either into a single Opportunity for the entire selection or into many Opportunities with one for each selection.

Following the product selection screen, a decision element evaluates the split option selected by the end user of creating either one or many Opportunities for the selected products. Depending on the selection, a corresponding path in the flow is followed.

The first action of the many Opportunities path is to loop through each of the products selected and, for each loop, assign values to a record variable for the creation of each new Opportunity. Once all products have been looped, the Opportunities are created using a collection variable of all the Opportunity record variables assigned.

Once the Opportunities have been created, each created Opportunity is looped, and for each Opportunity, all related products are looped. The first Product in the loop is assigned the ID of the current Opportunity in the loop. After the assignment, the Product is removed from the looped collection to avoid further assignment to all other Opportunities to be looped. Also, once an Opportunity has been assigned to a Product, a boolean variable is set to true, which triggers a decision element in the product loop to follow a path that avoids assigning all other products in the loop to the currently looped Opportunity. This variable is reset to false at the start of the next Opportunity in the loop.

The single Opportunity Path creates a single new Opportunity, then loops through the product selections, assigning an Opportunity Product variable for each product in the loop. Each Opportunity Product variable assigned is also added to a collection of Opportunity Products to create for the new Opportunity.

No matter the Opportunity Split option selected, the Opportunity Products are created from the collection variable, and the Opportunity Products selected from the originating Opportunity are deleted.

Once all Opportunity Products have been created/deleted, a table presents a list of the new Opportunities created for the selected product(s) with hyperlinks to each record.
Merging Opportunities

The Merge function allows for end users to combine multiple Open Opportunities shared by the same Account while also bringing over the related Opportunity Products, Contact Roles, and other related records. The first step of this function is to get any Open Opportunities related to the same Account outside of the current Opportunity. If no other Opportunities can be found, an error message is displayed to the end user informing them that there are no other Opportunities for the Account to merge with the current Opportunity. If Opportunities are found, then a merge selection screen will appear.

The merge selection screen presents a table of other Opportunities related to the same Account. End users select from this table which Opportunities they would like to merge with the current Opportunity.

After the merge selection, the Opportunity selection is looped, and a text collection of the Opportunity IDs is made. Using this text collection, all Opportunity products and Contracts related to the selected Opportunities are retrieved with get elements. Contracts in this use case have a custom lookup field that is used to relate them to Renewal Opportunities.
The next screen shown in the merge function is a table of all the Opportunity Products that will be merged under the current Opportunity as a result of the current selection. The end user must confirm the merge from this point forward, as the merge cannot be undone.

Once the merge is confirmed, the flow loops through all of the related Opportunity Products and assigns values from each product in the loop to a new Opportunity Product record variable. The record variable is added to a collection variable in the same loop.

Following the Opportunity Product loop, all related Contracts previously retrieved are looped as well. For each Contract in the loop, the "Renewal Opportunity" lookup field is assigned to equal the Opportunity that triggered the flow. The Contract in the loop is then added to a new collection of Contracts to be updated.

Following the Contract Loop, Content Document Links related to the merged Opportunities are retrieved. Content Document Links are records in Salesforce that link files to other records, such as Opportunities. If no Content Document Link records can be found, then no actions are performed. If records can be found, the Content Document Links are looped, values from each record are assigned to a record variable for the triggering Opportunity, and the record variable is added to a collection of Content Document Links to create. After the loop, Content Document Links for the triggering Opportunity are created using the previously assigned record collection.

After Content Document Links, Contact Roles from the triggering and merged Opportunities are retrieved. The Contact Roles are sorted by Contact Id ascending, then by Role ascending, and then by Primary descending. Primary Contact Roles are then filtered for using a collection filter, and a count of the filtered Contact Roles is assigned to a number variable.

A "Check Filter" decision element then checks the count of the filtered contact roles, and if more than 1 Contact cannot be found, no actions are performed. If more than 1 can be found, then the Primary Contacts previously filtered for are looped. Each looped Primary Contact is compared against the previous contact in the loop. If the previous and current Primary Contacts are not for the same contact, then the current Primary Contact in the loop is assigned to a Contact Role record variable for the triggering Opportunity. Also, the variable is added to a collection of Contact Roles to display in the next screen, shown if more than one unique primary contact is assigned.

If more than one unique Primary Contact is assigned in the previous loop, then a screen is displayed to the end user where they must select which of the Contacts should remain primary for the merged Opportunity.

Then the rest of the Contact Roles are looped, and during the loop, the current record in the loop is compared against the previous record in the loop. If the two records do not share the same Contact Id and Role, then the current record is added to a record variable and collection variable of Opportunity Contact Roles to create. This loop prevents the creation of any duplicate Contact Roles that could result from the Opportunity merge.

After the final Contact Role Loop, all Contact Roles for the triggering Opportunity are deleted, and new Contact Roles are created in the following element.

The last step of the merge process is to perform a series of action elements to dedicate the rest of the changes to the database. Opportunity Products are created, and Contracts are updated using respective collection variables assigned previously in the flow. The merged Opportunities are deleted from the database. In this use case, the final Opportunity is updated with a new naming convention, owner, record type, and stage value.
Also specific to this use case: Case records are linked to Opportunities with a custom lookup field. Any Case records related to the merged Opportunities are updated to be related to the triggering Opportunity. Lastly, a custom Log record is created recording the Opportunities that have been merged along with the actioning user. This log is also specific to just this use case.
Amending (Expanding) Opportunities

The Amendment (Expansion) option allows end users to edit existing products and add new ones for an existing Renewal Opportunity. The first step of this function is to get all Opportunity Products related to the triggering Opportunity and all Price Book Entries from the current standard price book. In this use case, only the standard Price Book is ever used.
With the retrieved records, a screen is shown where end users have the option to select products they would like to edit and add using two different tables for each option. Products must be selected from one or the other table to progress further in the flow.

After product selection, a "Check Amendments" decision element verifies that products have been selected to either be amended or added to the triggering Opportunity.
If no selection has been made, an error trigger variable is set true that displays an error message on the selection screen that the end user is redirected to. If products have been selected for amendment, the selection is looped and assigned to a record variabile that is then added to a collection of Opportunity Products. If no products are selected for amendment, then no actions are performed.

Following the product amendment check, another decision element, "Check Add Products", verifies if products have been selected from the “Add Products” table. If so, the products are looped and assigned to a record variabile that is then added to the same collection assigned during the “Amended Products” loop.
A table is shown, using the previously assigned collection, with lines for all products that are being added or amended. Each line allows for the end user to define the quantity and unit price for each product. Amended products will have the quantity and unit price predefined with values from the existing Opportunity Products on the Renewal. Added Products will have a default quantity of one and a unit price equal to the list price of the related price book entry.

After confirming the Opportunity Product details, the edited product lines are looped, assigned to a record variable with values define based on the product being an existing or non-existing line, and then assigned to a collection of Opportunity Products to created and update.

The final of actions of the Amend (Expand) Opportunities function updates the naming convention and type value for the triggering Opportunity. Also, Opportunity Products are created and updated from the Opportunity Products collection assigned in the previous loop.
Page Refresh Action

Both the Merge and Amend (Expansion) functions utilize a "Refresh Page" action at the end of their flow paths. This is a redirect action that redirects the user to the triggering Opportunity record. This essentially triggers a page refresh allowing the end user to see the resulting changes reflected instantly.
Final Thoughts
By leveraging Salesforce Flow to split, merge, and amend Opportunities, RevOps and Salesforce admin teams can unlock smarter, faster sales operations that truly reflect the complexity of modern B2B deals. These automations save time, reduce risk, improve data hygiene, and create a more agile CRM that scales with your business. Whether you're managing multi-product bundles, regional buying centers, or ongoing expansions, Flow gives you the control and flexibility to keep your pipeline clean and your sales process sharp. Start small, iterate fast, and let your automations do the heavy lifting.
The above Flow can be seen as a template for handling complex Opportunity automations for splitting, merging, and amending existing Opportunities and their related records. Although the Flow above is focused around Opportunity Products and a custom Subscription object, various other permutations are possible by adapting the logic.
If Opportunity management across new business, upsells and expansions, and renewals is something your business is struggling with, we'd love to chat. As growth business specialists, this is a common project we work on, and we're happy to share thoughts and best practices. Contact us here!