I have a requirement where, we need to send an Email on the status of failed Bulk Data Load jobs. But I am not sure the Object Name or how to refer those jobs programatically in my APex code. When I use 'AsyncApexJob', it's referring to Scheduled Apex Jobs. But I want the reference of Bulk Data Load Jobs. (Bulk Data Load jobs will be submitted by Mule ESB process using Salesforce Connectors.) Any info on this helps. Thanks.

  • 1
    I don't think they're tracked anywhere. With Data Loader, anyway, you store the results locally. – Adrian Larson Sep 7 '16 at 22:19
  • 2
    @AdrianLarson - I know bulk jobs are tracked in the UI: setup - jobs - bulk data load jobs. Is there an object for that? – Eric Sep 7 '16 at 22:56
  • 1
    You can always find SOJbectType if you have an Id: system.debug(Id.valueOf('<id_value>').getSObjectType()); – Adrian Larson Sep 7 '16 at 22:58

The object you seek is AsyncApiJob, but it can't be queried. Vote for this Idea: Ability to query AsyncApiJob from Apex.

I found this object by navigating to Setup > Jobs > Bulk Data Load Jobs. The url is along the lines of https://instance.salesforce.com/750?parameters=values. Since 750 looks like a key prefix, I tried:

system.debug(Id.valueOf('750000000000000').getSObjectType()); // yields AsyncApiJob

From there, finding the Idea linked above was straightforward.

  • 1
    Thanks for the confirmation. I just voted for the Idea which is very much required. – Amulya Sep 8 '16 at 14:37
  • Can't you use bulk API in VF and get the info ? youtube.com/watch?v=ZJFpUnQaF0s – Rao Sep 8 '16 at 19:02
  • @Rao I think the question was how to access them via Apex. Can you use the Bulk API in that context? – Adrian Larson Sep 8 '16 at 19:02
  • Adrian if it is context specific then no, your answer is closest. Also another way to look at it is through workbench which is similar to monitoring from UI. – Rao Sep 8 '16 at 19:06
  • @Rao - Basically our Siebel & SF applications are integrated using Mule ESB. Mule Service picks up the updated records from Integration table and sends to Salesforce using Bulk API call. SF connector handles all that processing which uses Salesforce Data Import wizard to Insert/Update records. It's all working well but occasionally, SF is taking more than 5 mins to load even single record & due to time out, Mule is marking that as Error. We are trying to make it Asynch (remove 5min limit) and thought of processing failed records later but looks like we can't access programatically. – Amulya Sep 8 '16 at 19:48

I ran into this same issue when developing a tool in Python to submit/check statuses of jobs submitted via the API.

I ended up using sfdx force:data:bulk:status -i 750XXXXXXXXXXXXXXX and then parsing the result back into a dict in order to be able to determine whether or not the job had completed or not.

Here's a link to the docs on the force:data commands.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.