function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sonu GSonu G 

i want to automate the opportunity renewal process by copying opportunity along with opportunity products.

Hi guys, my requirement is,

Create Renewal Opportunity - When opportunity stage is set to “Closed Won”, renewal
opportunity needs to be created with the following field mapping
Record type = “Renewal” (Create Opportunity Record Type, if not exist)
Account = Account of Original Opportunity
Type = Type of Original Opportunity
Stage = “Negotiation/Review”
Renewed from Opportunity = Original Opportunity (Create Lookup field of Opportunity on
Opportunity)
Close date = Close date of Original Opportunity + 10 Days
Name = “Renewal” + [SPACE] + Original Opportunity Name
2. Copy opportunity line Item to the renewal opportunity from Original Opportunity
Sumit Verma 41Sumit Verma 41
Hi Sonu G,
You can achieve the above mentioned requirements with the use of Process builder where in which it will call a autolaunched flow given that record type and additional lookup fields are already configured.
mritzimritzi
@Sonu
Write bulkified logic in an Apex class and call it from Opportunity trigger 'after update' context.
Filter Opportunities records that are closed-won, get related Order Products,  and create new recods.

Handling this use case with Process builder + Flow will results in SOQL query limit error, as flows are not bulkified and multiple queries will be fired when the trigger context will have multiple Opportunities matching the criteria.

If this helps solve your issue, please mark this as Best Answer, so that others can benefit too in future.
Somya TiwariSomya Tiwari

Hi Mrltzl & Sonu

What i feel is Process Buildder will be quite easy and will not require Apex classes. With Process Builder you will just need to assign the values of Opportunity and that's it. As we will not need to bulkify this thing. This will run on an opportunity getting closed won, and there will be rare cases where 1000s of opportunity will be converted to closed won.
In case of process builder just create a criteria check about Stage being changed to Closed Won. Then create a new Record of Opportunity type and map the fields accordingly.

Hope i was able to solve your query.

Regards,
Somya Tiwari

mritzimritzi
In process builder alone, you'll not be able to get related Opportunity Products, for that you will atleast need to call Flow to query all Opportunity Products related to given Oportunity, then copy Opportunity data as well as Opportunity Product.

Such operations hit limits very quickly if not bulkified, so if its target to be deployed in a Production system, its always recommended to implement a scalable solution (with bulkified query & DML operations).

If its just for practice in a developer org, then no worries.
Sonu GSonu G
Hi guys, can above requirement is achieved by using Apex triggers, if yes then please do give me solution.

thank you