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
Khemais MenzliKhemais Menzli 

A Scheduler Job is blocked by a Trigger

Hi everyone,
I created this new question, because I thought that the old title I have used in this Question :, didn't match with my need (Since I can't update the title of my question)
have a requirement to update each opportunity with data coming from a contact, to do it I created an apex scheduler that runs over all OpportunityContactRole in my Database and for each row I get the Contact+Opportunity then I do some logic to update opportunity with data coming from the corresponding contact.
I choosed to use a scheduler instead of a trigger because event on object OpportunityContactRole are not fired!!

I scheduled my apex-class (the scheduler) to be launched each day at 3 A.M
But when I go to «Apex Jobs» page to monitor the status of My Apex job, I see that the Job is failed with this status
JobType : Batch Apex
Status : Completed
StatusDetail :
First error: Update failed. First exception on row 0 with id 0060j0000024tVGAAY; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrackerTrigger: execution of AfterUpdate
caused by: System.AsyncException: Future method cannot be called fr...
Total Baches : 1
Baches proceeded : 1
Failures : 1

Thank's for help
Nayana KNayana K
You can go for defensive apex program.