+ 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 : https://developer.salesforce.com/forums/ForumsMain?id=9060G000000I87OQAS, 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.  https://www.slideshare.net/developerforce/defensive-apex-programming