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
iswarya sekar 7iswarya sekar 7 

Hii Everyone!! I need to write scheduler apex to send email to case Owner. If priority is high and caseclosed is true, it should send email on 5th business day from case created or updated date.

Shawn Reichner 29Shawn Reichner 29
I would just use a workflow rule or process with a time based action.  Then when your criteria is met you can set the time based email alert to fire 5 days after your workflow rule triggered or anothe date field on your case record. 

Hope this makes sense and helps,

Shawn
iswarya sekar 7iswarya sekar 7
hii, This is my batch apex. But when priority is high, its not updating CLOSED__C to True.
global class BatchApex implements Database.Batchable<sObject>
{
    String query = 'SELECT Id,CLOSED__c, Priority FROM Case';
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Case> cas)
    {
        for(Case c : cas)
        {
            if(c.priority=='High'){
                c.CLOSED__c = TRUE;           
            }
        }
        update cas;
    }
    global void finish(Database.BatchableContext BC)
    {
    }
    
}