You need to sign in to do that
Don't have an account?

Apex Job Schedule
I have creaed two feilds 1. Daily comment count 2. Total Comment Count and every day schedule the job at 12:00am so that daily comment will become 0 and added to Total comment count. However when schedule job is running on case the last updaed date is getting modifed as per the job run, below is the schedule job code.
global class CaseCommentCount_JobScheduler implements Schedulable {
global void execute (SchedulableContext sc)
{
List <Case> daily_UpdatedCaseList = new List<Case>();
List <Case> daily_CaseList = [select id,Daily_Comment_Count__c from case where Daily_Comment_Count__c > 0 AND Status !='Closed'];
System.debug('CaseCommentCount_JobScheduler : daily_CaseList size' + daily_CaseList.size());
for(case c : daily_CaseList ){
c.Daily_Comment_Count__c = 0;
daily_UpdatedCaseList.add(c);
}
update daily_UpdatedCaseList;
System.debug('CaseCommentCount_JobScheduler : daily_UpdatedCaseList size' + daily_UpdatedCaseList.size());
}
}
1. is there any other way without changing and modifed last updaed
2. I am planning to update the job every day at 9:00pm
3. Please help in the code to schedule the job everyday.
Regards
Shaker
1. We can't avoid changing the last modified date
2. And 3. Execute this in the execute anonymous in the developer console