Thursday, March 10, 2016

How to terminate AsyncApexJob [EXCEPTION: System.StringException: You can't abort scheduled apex ]

I thought this might be useful to developers. 

EXCEPTION: System.StringException: You can't abort scheduled apex : This exception may happen for 2 reasons
  1. It is not a CronTrigger ID (parent Id) for the Async Apex job 
  2. You are trying to delete a orphan Async Apex job, that is no parent Id.


Second situation is rare but it can happen. In that case you might face problem while deploying  the batch class again. The deployment will fail as the batch is already executing (queued )  for a long time.

If this happens you need to call saleesforce support to clear this. BUT before you call salesforce support please tray this which might help .

  1.  login to "https://workbench.developerforce.com/login.php
  2. On right corner, it will be showing your name and API version. Click on that link
  3. There you will find change API version, change it to 32
  4. Go to Utilities >> Apex Execute
  5. There run this command System.abortjob() with job Id

Please note the API version is very important we can't do this from developer console because we can't change the API version there, alternatively you may choose the version during login as well while logging -in to workbench. I believe this would help you. Please let me know if you have any other questions, I would love to help you in that as well.

Have a Great Day! 


No comments:

Post a Comment

Tips on passing Salesforce AI Associate Certification

  🌟 Motivation to Pursue the Salesforce AI Associate Certification 🌟 The world of technology is in a state of perpetual evolution, and on...