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
Sid LightningSid Lightning 

Batch apex to match unique key on Unrelated objects and create child record for one of them

Hi,

I want to write a batch class to execute the below function.

Objects Involved: Opportunity, Estimations, Orders, BRT, Achievements

Estimations and orders are child of opportunity
Achievements is child to BRT
Both look up to Business and Location ( separate custom objects)

BRT and Opportunity are unrelated



Unique Key on Opportunity is  Year-Month-Location-Business, same is the unique key on BRT

When the opportunity is closed won and if the unique key on opportunity matches with a unique key on BRT(master table). I want a class to run, that  creates a record in the achievement object(child to BRT)

Records captured at Achievement are

1) Opportunity: Opportunity Name
2) Opportunity: Created Date
3) Opportunity: Closed Won Date
4) Order: Order lookup( Order lookups to opportunity) 
5) Order: Order amount
6) Order: Billed Date
7) Estimations: Estimation Amount
8) Estimations: Month
9) Estimations: Start Date
10) BRT:  Targets

BRT being parent of Achievements, a lookup will be present, also I want to order no. to populated in order lookup provided at Achievements object.

Also if we have to provide estimations and opportunity lookup , its no problem.
since one opportunity can have multiple orders
Sid LightningSid Lightning
Can anyone help me on this?