In this help article we will explore how to clone an Opportunity while maintaining it’s Opportunity Products/Line Items.
Opportunity Products (Opportunity Line Items): These are the products or services added to an Opportunity in Salesforce. They include details like pricing, quantity, and discounts, and are associated with the Opportunity.
Example scenario: When a deal is lost but the customer requests a revised proposal, sales reps can clone the Opportunity along with all its products (Opportunity Line Items). This avoids the need to manually re-add each product, saving time and ensuring accuracy.
This tutorial shows how to build a Screen Flow that clones an Opportunity together with all of its Opportunity Products (Line Items), since Salesforce's standard clone feature does not carry line items over automatically.
Click New Flow from the flow menu within Salesforce setup. Choose Screen Flow.
Now we need to create a way to store the record Id of the Opportunity we're going to be on at the time — the one we want to clone.
Within Flow, navigate to Toolbox > Manager > New Resource:
Now that we've stored the record Id of the opportunity, we need to get the record in flow in order to get some of its details for the new cloned record.
Add Element > Get Records:
Once we've got the Opportunity record we need to also get the related Opportunity Product/Line Items.
Add Element > Get Records:
In this next step we need to create the cloned Opportunity record. We can do that by adding a Create Records element and mapping the relevant fields.
Add Element > Create Records:
Now, in order to add all of the Opportunity Products/Line Items, we need to loop over all of the ones associated to the old Opportunity, map the values we want to keep, and also point the new Opportunity Products/Line Items to the newly created Opportunity record. We do this by looping over all of the Opportunity Products/Line Items, using the Assign element to map our old Opportunity Products/Line Items into a new Opportunity Products/Line Items variable, keeping the values we want and ensuring the new Opportunity Id is added. Finally, to maintain a bulkified design, we add that newly created record variable to a collection, in order for us to create them all in one go.
Add Element > New Loop:
Add the resource to create the new Opportunity Product/Line Item record variable via Toolbox > Manager > New Resource:
Add the resource to store a collection of new Opportunity Products/Line Items via Toolbox > Manager > New Resource:
Add Element > New Assignment:
Do this for all values you wish to map. Note: ensure the newly created Opportunity Id is mapped:
Now add that record to a collection for bulkified record creation.
Add Element > New Assignment:
Add Element > Create Records:
Save & Activate your Flow.
Add your Flow to an Opportunity record page either as a flow component or a button.
Written by: Jonathan Fox | Salesforce Answers Leader. Jonathan Fox is the proud owner of the Trailblazer Golden Hoodie. He currently works as a Technical Architect for Intellect Design Arena, a Salesforce implementation partner in the FinServ industry. Salesforce Architect community group leader, Salesforce Military Trailblazer, and all-round advocate for the Salesforce platform, Jonathan looks to help and share wherever possible.
Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content, and other materials made available by or on behalf of third parties ("Third Party Materials"). Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality, usefulness, or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purport to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a "best" answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions. If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed
000396659

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.