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
MRDJMRDJ 

Apex Batch Class to update Field

There are 3 objects, Object1, Objec2 and Object3.

Object 1 and Object2 have relationship, Object 1 is parent and Object 2 is child. 
Need to update records on Object 3 based on the results from Object 1 and Object 2

Need apex batch class to update the flag on object 3.

Object 1: Parent Object
Field1: Id
Field2: OwnerId
Field3: Status

Fetch all the records from parent object: Select Id, OwnerId from Parent Object where Status='Submitted'
From this OwnerId is required

Object 2: Child Object
Field1: Id
Field2: Name (this is parent object Id, Field2)
Field3: Item Number
Field4: Item Name
Field5: COunt

Fetch all the child records of the corresponding soql result: Select Item Number, Item Name from Child Object where count=0 and Name in (above soql result of Ids)
From this Item Number, Item Name are required to map the OwnerId

Object 3: Different Object
Field 1: OwnerId (this ownerId is same as Field 2 in Object 1)
Field 2: Item Number (this Item number is same as Field3 in Object 2)
Field 3: Item Name (this Item name is same as Field4 in Object 2)
Field 4: Active

In this, active field should be set to false based on the corresponding OwnerId records of respective item numbers and names.
Shashikant SharmaShashikant Sharma
You could start reading batch class development from this and then post the issues which you face : 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm (http://blog.shivanathd.com/2013/01/how-to-write-batch-class-in.html)
http://blog.shivanathd.com/2013/01/how-to-write-batch-class-in.html