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
ckellieckellie 

Changing the PriceBook to a mature Opportunity

We are in the process of changing pricebooks to mass update all of our prices and costs. The challenge is we heavily use the quote object and are needing to requote opportunities that already have a quote record attached. In order to change a pricebook, one must delete the quote line items, quotes, and opportunity line items, which I think can be done with apex and visualforce. The general outline would be.

 

1. Unsync any Quote
2. Remove Quote Line Items, Quotes, Opportunity Line Items.
3. Change Price Book
4. Add Opportunity Line Items, Quotes, Quote Line Items

 

At one point in this process, the records will have to be stored in the code after the records are deleted and before the new records are created. At a conceptual leve, how do I store records and data in the code?

 

Has anyone seen this done before?

 

Thanks,

ckellie

Best Answer chosen by Admin (Salesforce Developers) 
WizradWizrad

If you use batch apex for this and keep the scope parameter small you can just store everything as variables in the code.

All Answers

WizradWizrad

If you use batch apex for this and keep the scope parameter small you can just store everything as variables in the code.

This was selected as the best answer
ckellieckellie

What do you mean by keep the parameter scope small?

WizradWizrad

Batch apex accepts an optional parameter, referred to as "scope".  If you keep it small you will not run into any SFDC Governor Limits.

 

Maybe you don't even need to keep it small, but the default is 200.  Try it with the default and if you run into governor limits lower the scope.

ckellieckellie

Perfect. Thank you