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
Linda 98Linda 98 

Clone opportunity and its products based on stage

Hi

I have a requirement where i need to clone oppportunity when a custom field is blank and stage is 'ready'.
Number of opportunities to be created by cloning from primary opportunity depends on a custom field called 'Number needed'

If number_needed__c = 10,then i want 9 opportunities to be created.

Name of each opportunity should be same but need to appened different number.For example:Primary opportunity =opportunity-need 1
then rest should be opportunity-need 2,opportunity-need 3,and so on..,

Any help on how i can get this?
I need some start up.Please help.

Thanks and kudos in advance.Please.

kroberts31.3887885794840894E12kroberts31.3887885794840894E12
When are the cloned opportunities supposed to be created? If it is as the primary is saved, then write a trigger. If it is as soon as a non-zero value is put in 'Number needed', then you are going to have to create a controller extension.
Linda 98Linda 98
I want opportunities to be cloned when stage is changed to 'ready' and if my custom field is blank.
Number of opportunities to be created will be the value in number_needed__c.
So i need to write a trigger on opportunity.

How can i clone opportunity with line items also  i am not understanding how can i write it with the name format as i mentioned in my above question.

please help.