I am getting list of opportunities and 1 master opportunity, using batch apex I am updating list of oppys from master oppy, what is the best way to know that child objects- say opportunityLineItems and attachments - are updated or not, if yes, the how can i update children?
For Example: I have an Opportunity with 2 OpportunityLineItems, 5 Activities and 10 Attachments. I want to clone this opportunity 200 times along with OpportunityLineItems and Attachments only using batch apex.
As per my understanding I have to create Batch Apex, In execute method I have to clone and insert the Opportunities first, then I have to clone Attachments and OpportunityLineItems for each of the Opportunity. But while doing so if I set the batch size to 20, it will throw the error of Heap Space.
Is there any efficient way to achieve this?
Thanks in advance.