You need to sign in to do that
Don't have an account?
Khemais Menzli
I get an exception when Apex Job starts
Hello every one,
I started working with SF apex to add some business to my company.
I 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
Any help is appriciated, I'm open to all suggestions
Thank's
I started working with SF apex to add some business to my company.
I 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
Any help is appriciated, I'm open to all suggestions
Thank's
You have an AFTER UPDATE trigger named OpportunityTrackerTrigger in your ORG which is causing trouble.
Can you post the code in the Trigger and your Batch Job as well? It will help us debug it better.
Code of OpportunityTrackerTrigger is (running as expected on production environment :
Code of Scheduler is :
Code of Job is :
I have Used the SFDC UI to setup when the scheduler is launched
I'm clueless, please I need help
I have did some reading on your issue.
And, I have found that the getContent() and getContentAsPDF() cannot be called from a Batch Apex.
Here are some articles that discuss about this and provide some work around.
https://developer.salesforce.com/forums/?id=906F0000000BP6DIAW
https://developer.salesforce.com/forums/?id=906F0000000AlGoIAK
Is your trigger tries to create a BLOB through the HTTPCallout.getContent()?
We may have to figure out an alternative way to incorporate this logic in the Batch Apex.