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.
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
Bulk Data Load Jobs. The url is along the lines of
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.
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!