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

Batch Apex Class


I have to write a batch apex class on two objects

1. Case 
2. Ticket__C

Ticket__c has a lookup to case and a case can have many ticket records but a ticket can only be associated to one case record

The Batch Apex class should run every morning at 2:00am and look at two fields(Status) in both the objects. Batch Apex shouls look at all the Cases and all the Tickets associated to the cases.

Case         -    Status (Field)
Ticket__c  -    GLOBAL_Ticket_Status__c (Field)

For example : if a case is associated with 3 Ticket__c records and the status of case is open, but status on 2 ticket__c records are closed and not the third record. Do not do anything.
If status of all the Ticket__c records are set to closed for a particular Case record but the Case record status itself is still open, Close the case after 7 days of Ticket__c records status closed. (This is because if business want to add a ticket to that particular case they can just because the case status is not closed).

Any help will be much appreciated

thank you
Phillip SouthernPhillip Southern
Hi, please post the code you have so far so we can troubleshoot.
hi Phillip,

The only issue is i have never written batch apex class before and any guidence as to how to go about getting the code written is much appreciated