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
baaskarbaaskar 

Getting incorrect previousFireTime value for my newly shceduled job

I am getting incorrect previousFireTime value for the newly shceduled job. It shows future time for example (---lastSchTime---2010-07-06 11:35:00) while it was scheduled at 07:35:00 am.

 

This is part of the scheduled class code

 

global void execute(SchedulableContext sc) {

    CronTrigger cronTrig = [Select id,PreviousFireTime,timesTriggered from CronTrigger where id=:sc.getTriggerId()];

    Datetime lastSchTime = cronTrig.PreviousFireTime;

    //List the Accnt team members which are modified after the last scheduled time.
                List<AccountTeamMember> latestUpdatedATMList = [Select id,userId,accountId,LastModifiedDate   
                        from AccountTeamMember where LastModifiedDate >: lastSchTime];

    ......

 

But still it is not fetching the recently modified account team member details (atestUpdatedATMList), since
previousfiretime field retrived as future date.

 

Can anyone help me out, if i coded incorrectly.

 

Regards,

baaskar

Nick34536345Nick34536345

The 4 hour difference is probably just the timezone. i.e. the job is scheduled for 7:35 in your time zone, but you're displaying (System.debug?) the previousFireTime in GMT.